我正在使用片段。我使用了Jake Whartons View Page指标。哪作得很好。但是,我想使用一个按钮来调用另一个片段活动。我该怎么做呢谢谢。
public class Question1 extends Fragment {
Button but1;
Communicator comm;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState){
View v = inflater.inflate(R.layout.question1, null);
return v;
}
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
but1 = (Button)getActivity().findViewById(R.id.qbut1);
but1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(getActivity(), Start.class);
getActivity().startActivity(myIntent);
}
});
}
public class Start extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.start, menu);
return true;
}