Ich möchte meine Werte hinzufügen, um Text zu bearbeiten, den ich in meiner Array-Liste gespeichert habe der Code hilft mir bitte weiter. Die Werte, die nicht in Text bearbeiten eingestellt sind.So fügen Sie Werte aus ArrayList hinzu <HashMap <String, String >> menuItems = new ArrayList <HashMap <String, String >> zum Bearbeiten von Text
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;
}}
Hier ist der Code bitte helfen Sie mir Werte in Text zu speichern.
Verwenden Sie die Karte woanders? Wenn nicht, warum steckst du nicht einfach die gewünschten Felder in die 'EditText' Komponenten? – Michael
Was ist das Problem, ** genau **? Bekommst du irgendwann eine Ausnahme? Wenn ja, was ist der Fehler und was ist die Linie? Oder stecken Sie fest und wissen nicht weiter? Wenn ja, wo bist du blockiert, was hast du versucht und warum hat es nicht funktioniert? – Raffaele
Ich habe Karte verwendet, um Werte von Web-Services zu bekommen, und wenn Werte in map sind, dann möchte ich diese Werte im Edit-Text speichern, aber es hat keine Werte gespeichert, sondern nur den Namen der Spalte –