我在傳遞意圖的imagebutton上得到forceclose。而不是傳遞intent我已經通過吐司onclick它已成功運行,但意圖傳遞沒有成功運行。forceclose onclick to passing intent
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();
}
}
}
後你的'code'或'logcat'請 – MAC 2013-04-06 05:51:36
發佈一些代碼和logcat。 – Ajay 2013-04-06 06:01:47
@Riddhi提供'code'&'Logcat'錯誤。 – GrIsHu 2013-04-06 06:06:40