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:
findViewById()
cannot be called from a PopupWindow, because PopupWindow does not have afindViewById()
method.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.(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 havefindViewById()
defined.)
Post a Comment for "Android Text View"