Here is the first page that contents fragment activity_fpage.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<ImageView
android:id="@+id/gymView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/arnold"
android:layout_centerHorizontal="true"
android:contentDescription="@string/appIcon"
android:src="@drawable/ic_launcher" />
<Button
android:id="@+id/newUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/arnold"
android:layout_centerHorizontal="true"
android:minWidth="288dip"
android:text="@string/newUser" />
<fragment
android:id="@+id/fragmet_user_list"
android:name="com.example.gym1_1.ListOfUsers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/newUser" />
next is the java file for fragment
import android.app.ListFragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
public class ListOfUsers extends ListFragment implements OnClickListener {
String data[] = new String[] { "Matt", "Ken", "July", "Trish" };
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1, data);
setListAdapter(adapter);
}
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(),com.example.gym1_1.MainActivity.class);
startActivity(intent);
}
}
but the main class where the shown layout launches is
public class First_page extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fpage);
}
The question is how to make "Matt", "Ken", "July", "Trish" clickable, by clicking which user would be sent to the next activity with with clicked name put in extras? Thanks