I\'m working with ViewPager with 3 Fragments and I want to change text of TextView in third page.
In that page I have a
You cant access text view from fragment activity because its located on fragment and your fragment activity layout don't have any text view with this id. You have to access text view from your third fragment where you used it in its layout. Then access that object from your fragment activity.
in your fragment do something like this
TextView mTextView;
mTextView = (TextView)getView().findViewById(R.id.your_text_view);
Create a function like this
public void changeText(String mText)
{
mTextView.setText(mText);
}
In your activity result
//Do not create new object each time you set text. Use the same fragment object which you use for view pager.
Your_Fragment mFragment;
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case FILE_SELECT_CODE:
if (resultCode == RESULT_OK) {
//Set text from here
mFragment.changeText(imgName);
}
You can to inflate a layout in which textView is declared:
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.your_layout, this, false);
and then:
textViewImg = (TextView) view.findViewById(R.id.textViewUrlImgLectura);