I have used a viewpager in my app in which i have a number of pagers. In this pages i have a TextView and a Button and i want to be able to change the textview in the one pager when the button in that pager is clicked.
I have the code below, but the text doesn't change when i click on the button.
@Override
public Object instantiateItem(ViewGroup collection, int position) {
View view = null;
LayoutInflater h = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = h.inflate(R.layout.content, null);
tvName = (TextView) view.findViewById(R.id.tvName);
btnView = (Button) view.findViewById(R.id.viewBTN);
tvName.setText("Original Text")
btnView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
tvName.setText("new Test")
}
});
collection.addView(view);
return view;
}