|
|
|
Android - Intent back to current TabHost สอบถามปัญหาการส่ง หน้าคืนกลับมาที่ Activity ที่สองของ TabHost ครับ |
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-10-26 15:30:35 |
By :
t33l3x |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเอา Code มาดูหน่อยครับ
|
|
|
|
|
Date :
2013-10-27 08:09:38 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (Android-Java)
protected void onCreate(Bundle savedInstanceState) {
/*The exception that is thrown when an application attempts to perform a networking operation on its main thread. See StrictMode below*/
//StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
//StrictMode.setThreadPolicy(policy);
/*-------------------------------------------------------------------------------------------------------------------------------------*/
super.onCreate(savedInstanceState);
setContentView(R.layout.tabmanu);
Intent inboundIntent = getIntent();
String user_name = inboundIntent.getExtras().getString("username");
String n = user_name;
Log.d("userTab" ,n);
Resources res = getResources();
TabHost tabHost = this.getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this.getApplicationContext(), Income.class);
Bundle bundle = new Bundle();
bundle.putString("username", n); //SEND USERNAME FROM LOGIN PAGE TO NEXT LAYOUT PAGE
intent.putExtras(bundle);
spec = tabHost.newTabSpec("Income").setIndicator("income").setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this.getApplicationContext(), Expense.class);
Bundle eBundle = new Bundle();
eBundle.putString("username", n);
intent.putExtras(eBundle);
spec = tabHost.newTabSpec("Expense").setIndicator("expense",res.getDrawable(R.drawable.expense))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this.getApplicationContext(), Reports.class);
spec = tabHost.newTabSpec("REPORT").setIndicator("report").setContent(intent);
tabHost.addTab(spec);
} // End of onCreate Method
}
|
|
|
|
|
Date :
2013-11-02 17:21:15 |
By :
t33l3x |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (Android-Java)
addType.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(getApplicationContext(),AddExpense.Code (Android-Java)
Bundle bundle = new Bundle();
bundle.putString("user_name", n);
myIntent.putExtras(bundle);
startActivity(myIntent);
}
});
อันนี้เป็นอีเวน เรียกอีกหนึ่งคลาสมาทำงานครับ
ผมเรียกคลาสนี้ขึ้นมา
Code (Android-Java)
saveEx.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(SaveData()){
setIntent(n);
}
}
});
public boolean SaveData(){
final AlertDialog.Builder adb = new AlertDialog.Builder(this);
AlertDialog ad = adb.create();
if(tAccountName.getText().length() == 0){
ad.setMessage("Please Input Expense");
ad.show();
return false;
}
myDBClass myDb = new myDBClass(this);
/* Check Data before save */
String arrData[] = myDb.SelectExpenseData(tAccountName.getText().toString());
if(arrData != null){
ad.setMessage("Expense Data Already exists...");
ad.show();
return false;
}
String tAccountID = null ;
long saveStatus = myDb.InsertDataExpense(tAccountID, tAccountName.getText().toString());
if(saveStatus <= 0){
ad.setMessage("ERROR!!!");
ad.show();
return false;
}else{
showListView();
Toast.makeText(AddExpense.this, "Add Data Successfully. ",Toast.LENGTH_SHORT).show();
}
return false; //For Show ListView in normally will set return true
}
public void setIntent(String strUser){
Intent myIntent = new Intent(AddExpense.this, Expense.class);
Bundle bundle = new Bundle();
bundle.putString("username",strUser);
myIntent.putExtras(bundle);
finish();
startActivity(myIntent);
}
จากนั้นก็ Intent กลับ Code ในความเห็น No.3 ครับ
ปล.ตอนนี้ผม แก้ขัดโดยการ Override onBackPressed() ไปก่อนครับ
|
ประวัติการแก้ไข 2013-11-02 17:31:19 2013-11-02 17:32:33
|
|
|
|
Date :
2013-11-02 17:28:26 |
By :
t33l3x |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|