2016-04-27 110 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

相关问题