我正在製作一個應用程序,您可以使用單選按鈕和複選框從不同的事物中進行選擇。所以我想知道如何讓選定的數據出現在另一項活動中?數據使用單選按鈕/複選框從一個活動顯示在另一個?
這是你選擇你想要什麼咖啡的班級。
package com.coffee2go.coffee2go;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
public class coffee2 extends Activity {
private RadioGroup choosecoffee;
private Button order;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.coffee2);
choosecoffee = (RadioGroup) findViewById(R.id.choosetypeofcoffee);
order = (Button) findViewById(R.id.order_coffee);
addListenerOnButton();
}
private void addListenerOnButton() {
// TODO Auto-generated method stub
order.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(coffee2.this, order.class));
}
});
choosecoffee.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(coffee2.this, order.class));
}
});
}
}'
這是我希望信息出現的類。該信息還應該被保存下來到MySQL數據庫在Web服務器上000webhost.com
'package com.coffee2go.coffee2go;
import android.app.Activity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
public class order extends Activity {
private RadioGroup choosecoffee;
private RadioButton bryggkaffe, latte, espresso;
private RadioGroup sizeofcoffee;
private RadioButton small, big;
private CheckBox sugar, milk;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.order);
TextView orderlist = (TextView) findViewById(R.id.orderlist);
TextView pricelist = (TextView) findViewById(R.id.pricelist);
choosecoffee = (RadioGroup) findViewById(R.id.choosetypeofcoffee);
bryggkaffe = (RadioButton) findViewById(R.id.bryggkaffe);
latte = (RadioButton) findViewById(R.id.latte);
espresso = (RadioButton) findViewById(R.id.espresso);
sizeofcoffee = (RadioGroup) findViewById(R.id.choosecoffeesize);
small = (RadioButton) findViewById(R.id.small);
big = (RadioButton) findViewById(R.id.big);
sugar = (CheckBox) findViewById(R.id.sugar);
milk = (CheckBox) findViewById(R.id.milk);
if (bryggkaffe.isChecked() == true) {
orderlist.append("Bryggkaffe\n");
}
if (latte.isChecked() == true) {
orderlist.append("Latte\n");
}
if (espresso.isChecked() == true) {
orderlist.append("Espresso\n");
}
if (small.isChecked() == true) {
orderlist.append("Liten\n");
}
if (big.isChecked() == true) {
orderlist.append("Stor\n");
}
if (sugar.isChecked() == true) {
orderlist.append("Socker\n");
}
if (milk.isChecked() == true) {
orderlist.append("Mjölk\n");
}
}'
有什麼辦法,使這個?我是否需要建立連接類和php?
用很少的評論發佈你的整個代碼可能不會有幫助 - 發佈你遇到問題的地方。你想要做什麼來獲得你想要的東西? –