Android Problem Calling Textview From Second Layout File
Solution 1:
You first need ot inflate the other xml layout file in order to be able to do stuff on the TextView.
(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE).inflate(R.layout.display_item);
Solution 2:
I think you can solve yuor problems with Intent data. You're starting your activity via Intent, right? If so, just pass desired data (cur...) via Intent and that's it.
Solution 3:
What you are doing should not be done unless you are embedding the layout in the current layout (layout 1) and in that case you need to use include layout.
In case you want to access data and set it from one activity to another. Use SharedPreference to store the text in this activity and when the other activity launches which used the second layout as its content view, you can use this SP to access the data and set the text view.
Solution 4:
As Second TextView is the part of another layout so we have to used
setContentView(R.layout.R.layout.display_item);
So for second TextView Change you code to
setContentView(R.layout.display_item);
TextViewcurrency= (TextView) findViewById(R.layout.display_item/R.id.currency);
currency.setText(cur);
Post a Comment for "Android Problem Calling Textview From Second Layout File"