3
我想增加自己的價值觀來編輯,我保存在我的數組列表,這裏是正文代碼請幫助我。未在編輯文本中設置的值。如何從ArrayList中添加值<HashMap的<字符串,字符串>>的菜單項=新的ArrayList <HashMap的<字符串,字符串>>編輯文本
public class AgentProfile extends Activity {
EditText edtname,edtaddress,edtmobile,edtfather;
Button bback;
private SimpleAdapter adapter;
static final String KEY_TABLE = "AGENTPROFILE";
static final String KEY_NAME = "AGENTNAME";// parent node
static final String KEY_ADDRESS = "ADDRESS";// parent node
static final String KEY_COUNTRY= "COUNTRY";
static final String KEY_MOBILE = "MOBNO1";
static final String KEY_FATHER= "FATHERNAME";
ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_agent_profile);
edtname= (EditText) findViewById(R.id.edtname);
edtaddress= (EditText) findViewById(R.id.edtaddress);
edtmobile= (EditText) findViewById(R.id.edtmobile);
edtfather= (EditText) findViewById(R.id.edtfather);
bback= (Button) findViewById(R.id.btnback);
select s=new select();
s.execute("");
bback.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(AgentProfile.this, MainActivity.class);
startActivity(i);
}
});
}
public class select extends AsyncTask<String,Void, String> {
HashMap<String, String> map = new HashMap<String, String>();
@Override
protected String doInBackground(String... strings) {
WebServiceCall com = new WebServiceCall();
Intent intent =getIntent();
Bundle b =intent.getExtras();
final String string1 = getIntent().getStringExtra("Agentid");
// messageBox("test", Agentid);
String strXml=com.BP("AgentProfile",string1);
//messageBox("test", strXml);
XMLParser parser = new XMLParser();
Document doc = parser.getDomElement(strXml); // getting DOM element
NodeList nl = doc.getElementsByTagName(KEY_TABLE);
//String[] arList = null;
//String[] arListkey = null;
// int conttotal=0;
// looping through all item nodes <item>
for (int i = 0; i < nl.getLength(); i++)
{
// creating new HashMap
Element e = (Element) nl.item(i);
// adding each child node to HashMap key => value
map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
map.put(KEY_ADDRESS, parser.getValue(e, KEY_ADDRESS));
map.put(KEY_COUNTRY, parser.getValue(e, KEY_COUNTRY));
map.put(KEY_MOBILE, parser.getValue(e,KEY_MOBILE));
map.put(KEY_FATHER, parser.getValue(e, KEY_FATHER));
// adding HashList to ArrayList
menuItems.add(map);
}
return strXml;
}
@Override
protected void onPostExecute(String s) {
edtmobile.setText(KEY_MOBILE);
edtfather.setText(KEY_FATHER);
}
}
private boolean connectionAvailable() {
boolean connected = false;
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED ||
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED ||
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE_SUPL).getState() == NetworkInfo.State.CONNECTED) {
//we are connected to a network
connected = true;
}
return connected;
}}
這裏是代碼請幫我出來在編輯文本中存儲值。
你使用地圖其他地方?如果沒有,你爲什麼不乾脆把所需的字段對入'EditText'組件? – Michael
什麼問題,究竟** **?某些時候你會遇到異常情況嗎?如果是這樣,什麼是錯誤的,什麼是行?或者你卡住了,不知道如何繼續?如果是這樣,你在哪裏阻塞,你嘗試了什麼,爲什麼它沒有工作? – Raffaele
我使用map從Web服務獲取值,之後,如果值在映射中,那麼我想在編輯文本中存儲這些值,但它沒有存儲值,它只是將列的名稱 –