2016-04-27 107 views
1
public class activityresult2 extends Activity { 

static public String txtOrder =""; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_activityresult2); 

    Bundle bundle = getIntent().getExtras(); 
    String strfnq = bundle.getString("Noodle quantity"); 
    String strfrq = bundle.getString("Rice quantity"); 
    String strfsq = bundle.getString("Fish quantity"); 
    String stricq = bundle.getString("Iced tea"); 
    Integer strsum = bundle.getInt("sum"); 

    boolean addNingc = bundle.getBoolean("ANI"); 
    boolean addRingc = bundle.getBoolean("ARI"); 
    boolean addFingc = bundle.getBoolean("AFI"); 
    boolean addTingc = bundle.getBoolean("AIT"); 
    boolean addmoneyc = bundle.getBoolean("AMY"); 

    Intent mIntent = getIntent(); 

    int sum = mIntent.getIntExtra("sum",strsum); 
    TextView costtext = (TextView)findViewById(R.id.costtext); 
    costtext.setText(String.valueOf(sum)); 

    TextView foodorders = (TextView) findViewById(R.id.foodordershow); 
    foodorders.setText(getIntent().getExtras().getString("Quantity")); 

    String addNdlThing = ""; 
    if (addNingc) { 
     addNdlThing = " with addition of ingredients"; 
    } 

    String addRlThing = ""; 
    if (addRingc) { 
     addRlThing = " with addition of ingredients"; 
    } 

    String addSlThing = ""; 
    if (addFingc) { 
     addSlThing = " with addition of ingredients"; 
    } 

    String addTeac = ""; 
    if (addTingc) { 
     addTeac = " with addition of ingredients"; 
    } 

    foodorders = (TextView) findViewById(R.id.foodordershow); 
    if(strfnq.equals("") && strfrq.equals("") && strfsq.equals("")&& stricq.equals("")){ 
     txtOrder = "Sorry, You've not ordered any thing , please return to previous menu to order"; 
    }else if (!strfnq.equals("") && !strfrq.equals("") && !strfsq.equals("")&& stricq.equals("")) { 
     txtOrder = "Thank you , You've ordered\n" + strfnq + " fried noodle" + addNdlThing +" and\n"+ strfrq 
       + " fried rice" + addRlThing +" and\n" + strfsq + " Steam fish " + addSlThing + "and\n" + stricq + " Steam fish " + addTeac; 
    } else { 
     txtOrder = "Thank you , You've ordered\n"; 
     if(!strfnq.equals("")){ 
      txtOrder = txtOrder + strfnq + " fried noodle" + addNdlThing; 
     } 
     if(!strfrq.equals("")){ 
      txtOrder = txtOrder + strfrq + " fried rice" + addRlThing; 
     } 
     if(!strfsq.equals("")){ 
      txtOrder = txtOrder + strfsq + " Steam fish" + addSlThing; 
     } 
     if(!stricq.equals("")){ 
      txtOrder = txtOrder + stricq + " Iced Tea"+ addTeac; 
     } 
    } 
    foodorders.setText(txtOrder); 
} 

後,我在前面的頁面是activityresult1選擇我的食物,我的食物的TextViewfoodorders顯示在這個頁面(activityresult2),下...如果我按下此頁面上的一個按鈕,我想所有的項目顯示在foododers存儲在我的wampserver數據庫是MySQL數據庫,做任何人都知道該怎麼做如何將數據存儲在wampserver

+0

使用Android SDK中您無法連接MySQL服務器。您必須創建服務器端腳本來管理將數據存儲在mysql數據庫中。您可以使用http連接將數據發送到腳本。 – USKMobility

+0

@USKMobility,你知道該怎麼做,如果是的話,請給我發電子郵件至[email protected] – Vyshunavi

+0

等待等待。你想數據庫必須在互聯網上或只是在android應用程序內? Android有SQLite用於存儲食品訂單,僅適用於設備上的數據。如果你想連接到在線數據庫,它會更棘手,但你可以用WAMP建立一個網站,並用android中的httpurlconnect解析數據。 –

回答

1

首先配置WAMP的服務器在本地主機環境。 1)獲得你的機器的IP地址 2)點擊wamp服務器中的putonline按鈕。 3)編寫一個php腳本來將數據存儲在mysql中。 4)調用PHP腳本從您的移動像(http://192.168.0.5/package名/ php文件名)

檢查此鏈接:http://androidprogramz.blogspot.in/2012/07/connect-mysql-database-from-android.html

+0

我已經做到了,我只是想補充,但我不知道如何將它添加到我的數據庫中,請給我發電子郵件在[email protected] – Vyshunavi

+0

嗨,你能pelase幫助我 – Vyshunavi

相關問題