配列リストに格納されたテキストを編集するために値を追加したいコードは私を助けてください。編集テキストで設定されていない値。ArrayList <HashMap <String、String>から値を追加する方法menuItems = new ArrayList <HashMap <String、String >>テキストを編集する
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
Webサービスから値を取得するためにマップを使用しました。その後、値がマップにあれば、これらの値を編集テキストに格納しますが、列の名前を格納する値は格納されませんでした –