I'm new to Android app programming.
I have two Fragments - fragmentA.xml
and fragmentB.xml
.
In fragmentA
there are two Buttons - Button One (id: btnOne
) and Button Two (id: btnTwo
).
In fragmentB
there is TextView (id- textView
)
In fragmentB
java class there are two String
- string1
and string2
Both buttons refers to fragmentB
.
I want two set the textView
text to string1
when I press Button One
and string2
when I press Button Two.
How can I do that?
I was using following code in fragmentB
java class to display only string1
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.oop_page,container,false);
TextView textV = (TextView)rootView.findViewById(R.id.textView);
textV.setText(string1);
return rootView;
}
Can I use any if-else statement here?
Thanx