あるタブから別のタブにインテントを渡したい。最初のフラグメントのボタンを押すと、他のフラグメント (アクティビティなど) に移動する必要があります。startActivity(new Intent(EntryTab.this, Journals.class)); のようなフラグメントでこれを行う別の方法はありますか? ? 以下は私のコードで、startActivity 行にエラーが表示されます。助けてください!
public class EntryTab extends Fragment{
public static final String LOGTAG = "BALANCE";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.entries, container, false);
Button save = (Button) ll.findViewById(R.id.entriesButton);
save.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
BalanceApp myapp= (BalanceApp) getActivity().getApplicationContext();
DataSource datasource = myapp.datasource;
datasource.open();
Log.i(LOGTAG,"inside tab entry");
EditText amount = (EditText) ll.findViewById(R.id.amount);
int amt = Integer.parseInt(amount.getText().toString());
EditText debit = (EditText)ll.findViewById(R.id.debitText);
String dr = debit.getText().toString();
EditText credit = (EditText)ll.findViewById(R.id.creditText);
String cr = credit.getText().toString();
datasource.createEntry(dr, "DR", amt);
datasource.createEntry(cr, "CR", amt);
Cursor c=datasource.database.rawQuery("SELECT * FROM entries", null);
c.moveToFirst();
// Log.i(LOGTAG, dr + " " + amt + " " + cr );// the last row
Log.i(LOGTAG, c.getString(0) + " " + c.getString(1) + " " + c.getString(2) );// shows always the first row
datasource.close();
startActivity(new Intent(EntryTab.this, Journals.class)); // error: the constructor intent is undefined.
}
});
return ll;
}
}