I am new to java, and I am still learning, can anyone help in this respect in their spare time?I am trying to do a 10 page poem, just to start with.
I have created buttons that look like a number pad, I am trying to make this number work when it has been pressed/clicked. I am able to make the numbers show when pressed. However, where I am having problems is how to make this number open another layout I have created with a number.
Say I have created a layout and I want it to be page 7, how do I set it such that when number 7 is pressed (it shows the first line / title of the poem) and when the "Go" button is clicked, it opens the layout with poem number 7.
Thank you
EDIT
I followed what you told me and now I have one layout and one fragment class.
`<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<android.support.v4.view.ViewPager
android:id="@+id/text_fragment_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/tvpoem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
`
and the fragment java class is like:
public class PoemMapFrag extends Fragment
`{ @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragpoemsmap, container, false);
TextView fragpageone = (TextView) view.findViewById(R.id.tvpoems);
fragpageone.setText("Testing");
return view;
}
public View onCreateView1(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragpoemsmap, container, false);
TextView fragpagetwo = (TextView) view.findViewById(R.id.tvpoems);
fragpagetwo.setText("Yawning");
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
}`