How to Change xml from listView

zarocks

New Member
I have list and I want to change the screen according to clik item. I have two arraylist and first arraylist handle list items and second list handle the another pages. when I click the first item on the list the scrren cahanges and coming first item on the mylist2. my code is here:\[code\] package com.pxr.tutorial.json;import java.util.ArrayList;import java.util.HashMap;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;import org.w3c.dom.Document;import org.w3c.dom.Element;import org.w3c.dom.NodeList;import com.pxr.tutorial.xmltest.R;import android.app.ListActivity;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.AdapterView;import android.widget.AdapterView.OnItemClickListener;import android.widget.ArrayAdapter;import android.widget.ListAdapter;import android.widget.ListView;import android.widget.SimpleAdapter;import android.widget.TextView;import android.widget.Toast;public class Main extends ListActivity { String data; Uri uri; ArrayList mylist2 = new ArrayList(); TextView text; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listplaceholder); //arraylist i?erisinde bir hash map tasarlan?r. ArrayList mylist = new ArrayList (); //json'un oldu?u url tan?mlan?r. JSONObject json = JSONfunctions.getJSONfromURL("http://hub.donelabs.com:8180/HubServices/GetApplications?id=0&platform="); try{ //json'un i?erisindeki arraylar ?ekilir. JSONArray array = json.getJSONArray("app_array"); //ka? tane array varsa hesaplan?r for(int i=0;i<array.length();i++){ mylist.add("App Name:" + e.getString("app_name")); } }catch(JSONException e) { Log.e("log_tag", "Error parsing data "+e.toString()); } try{ //json'un i?erisindeki arraylar ?ekilir. JSONArray array = json.getJSONArray("app_array"); //ka? tane array varsa hesaplan?r for(int i=0;i<array.length();i++){ JSONObject e = array.getJSONObject(i); mylist2.add("Info: " + e.getString("app_info")); } }catch(JSONException e) { Log.e("log_tag", "Error parsing data "+e.toString()); } setListAdapter(new ArrayAdapter<String>(Main.this,android.R.layout.simple_list_item_1, mylist)); } @Override public void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub super.onListItemClick(l, v, position, id); Object o = this.getListView().getItemAtPosition(position); String pen = mylist2.get(position).toString(); //Toast.makeText(this, ""+pen, Toast.LENGTH_SHORT).show(); //sayfay? ayrla text = (TextView) findViewById(R.layout.example); text.setText(pen); //sayfay? a?t?r Intent intent = new Intent(this, Change.class); startActivity(intent); finish(); /* * String yeni = position; Change chg = new Change(yeni); Intent intent = new Intent(this, Change.class); intent.putExtra(yeni, chg); */ }}\[/code\]Change.java class:\[code\]package com.pxr.tutorial.json;import com.pxr.tutorial.xmltest.R;import android.app.Activity;import android.os.Bundle;public class Change extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.example); }}\[/code\]when I want to run my face the problem forcing close. where is my wrong?
 
Back
Top