我在传递意图时在 imagebutton 处强制关闭。我没有传递意图,而是在 onclick 上传递了 toast,它已成功运行,但传递的意图未成功运行。
enter code here:
有什么可能???
package com.account;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
public class AccountTrackerActivity extends Activity implements OnClickListener{
ImageButton user;
ImageButton acc_list;
ImageButton add_acc;
ImageButton add_transaction;
ImageButton search_trans;
ImageButton remainder;
ImageButton recent_trans;
TextView curr_user;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
user=(ImageButton)findViewById(R.id.imageButton2);
acc_list=(ImageButton)findViewById(R.id.imageButton3);
add_acc=(ImageButton)findViewById(R.id.imageButton4);
add_transaction=(ImageButton)findViewById(R.id.imageButton6);
search_trans=(ImageButton)findViewById(R.id.imageButton7);
remainder=(ImageButton)findViewById(R.id.imageButton8);
recent_trans=(ImageButton)findViewById(R.id.imageButton5);
curr_user= (TextView)findViewById(R.id.lblcurrent_user);
user.setOnClickListener(this);
acc_list.setOnClickListener(this);
add_acc.setOnClickListener(this);
add_transaction.setOnClickListener(this);
search_trans.setOnClickListener(this);
remainder.setOnClickListener(this);
recent_trans.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try
{
if(v.getId()==user.getId()){
Intent myIntentlogin=new Intent(AccountTrackerActivity.this,login.class);
startActivityForResult(myIntentlogin,101);
}
if(v.getId()==acc_list.getId()){
//Intent myIntentacc_list=new Intent(getApplicationContext(),acc_list.class);
Toast.makeText(getApplicationContext(),"hi....", Toast.LENGTH_LONG).show();
//startActivityForResult(myIntentacc_list,101);
//startActivity(myIntentacc_list);
}
if(v.getId()==add_acc.getId()){
Intent myIntentadd_acc=new Intent(AccountTrackerActivity.this,add_acc.class);
startActivityForResult(myIntentadd_acc,103);
}
if(v.getId()==add_transaction.getId()){
Intent myIntentadd_transaction=new Intent(AccountTrackerActivity.this,add_transaction.class);
startActivityForResult(myIntentadd_transaction,104);
}
if(v.getId()==search_trans.getId()){
Intent myIntentsearch_trans=new Intent(AccountTrackerActivity.this,search_trans.class);
startActivityForResult(myIntentsearch_trans,105);
}
if(v.getId()==remainder.getId()){
Intent myIntentremainder=new Intent(AccountTrackerActivity.this,remainder.class);
startActivityForResult(myIntentremainder,106);
}
if(v.getId()==recent_trans.getId()){
Intent myIntentrecent_trans=new Intent(AccountTrackerActivity.this,recent_trans.class);
startActivityForResult(myIntentrecent_trans,107);
}
}
catch(Exception e)
{
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}