Skip to content Skip to sidebar Skip to footer

Android Text View

I am creating a pop up window in click event, inside that pop up window there are text view and Button... If I create an Id in XML and set the text by TextView txt=(TextView)findVi

Solution 1:

You are calling findViewById() on the View that got clicked, not your popup window.

Change this:

holder.text1 = (TextView) view.findViewById(R.id.pop_txt);

To:

holder.text1 = (TextView) pw.findViewById(R.id.pop_txt);

Solution 2:

PopupWindow is not a View in android. In fact, PopupView extends Object directly - this means a couple things:

  1. findViewById() cannot be called from a PopupWindow, because PopupWindow does not have a findViewById() method.

  2. When findViewById() tries to traverse the UI tree, it can't find the elements inside of it, because the PopupWindow is not actually a View in the hierarchy.

  3. (I think) this means PopupWindow can't be used for dynamic content. You will have to use a Dialog instead, which actually has a findViewById() method available. (Dialog is also not a View, but it does have findViewById() defined.)

Post a Comment for "Android Text View"