|
![](/images/resource/spacer.gif) |
|
Android - Intent back to current TabHost สอบถามปัญหาการส่ง หน้าคืนกลับมาที่ Activity ที่สองของ TabHost ครับ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
![](/images/bbcode/ehh.gif?v=1001)
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2013-10-26 15:30:35 |
By :
t33l3x |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ลองเอา Code มาดูหน่อยครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2013-10-27 08:09:38 |
By :
mr.win |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
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
}
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2013-11-02 17:21:15 |
By :
t33l3x |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
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
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2013-11-02 17:28:26 |
By :
t33l3x |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 05
|