Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将数据从listview传递到另一个listview_Android_Listview - Fatal编程技术网

Android 如何将数据从listview传递到另一个listview

Android 如何将数据从listview传递到另一个listview,android,listview,Android,Listview,在下一个活动中单击时,如何从一个listview传递到另一个listview?我在我的数据库中检索了我的数据,我试图通过它们的ID过滤选择,并在单击listview中的项目时显示来自同一ID的所有内容 这是我的第一个活动中的onclick列表视图 @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent =

在下一个活动中单击时,如何从一个listview传递到另一个listview?我在我的数据库中检索了我的数据,我试图通过它们的ID过滤选择,并在单击listview中的项目时显示来自同一ID的所有内容

这是我的第一个活动中的onclick列表视图

@Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Intent intent = new Intent (this, Sample.class);
        HashMap<String,String> map =(HashMap)parent.getItemAtPosition(position);
        String s_id = map.get(Config.TAG_s_id).toString();
        String s_name = map.get(Config.TAG_s_name).toString();
        String s_gender = map.get(Config.TAG_s_gender).toString();
        String teamone = map.get(Config.TAG_teamone).toString();
        String teamonepts = map.get(Config.TAG_teamonepts).toString();
        String teamtwo = map.get(Config.TAG_teamtwo).toString();
        String teamtwopts = map.get(Config.TAG_teamtwopts).toString();
        intent.putExtra(Config.S_id,s_id);
        intent.putExtra(Config.S_name,s_name);
        intent.putExtra(Config.S_gender,s_gender);
        intent.putExtra(Config.Teamone,teamone);
        intent.putExtra(Config.Teamonepts,teamonepts);
        intent.putExtra(Config.Teamtwo,teamtwo);
        intent.putExtra(Config.Teamtwopts,teamtwopts);
        startActivity(intent);
    }
@覆盖
public void onItemClick(AdapterView父对象、视图、整型位置、长id){
意向意向=新意向(此,Sample.class);
HashMap=(HashMap)parent.getItemAtPosition(position);
字符串s_id=map.get(Config.TAG_s_id.toString();
字符串s_name=map.get(Config.TAG_s_name.toString();
字符串s_gender=map.get(Config.TAG_s_gender.toString();
String teamone=map.get(Config.TAG_teamone.toString();
字符串teamonepts=map.get(Config.TAG_teamonepts.toString();
String teamtwo=map.get(Config.TAG_teamtwo.toString();
String teamtwopts=map.get(Config.TAG_teamtwopts.toString();
intent.putExtra(Config.S_id,S_id);
intent.putExtra(Config.S_name,S_name);
intent.putExtra(配置S_性别,S_性别);
intent.putExtra(Config.Teamone,Teamone);
intent.putExtra(Config.Teamonepts,Teamonepts);
intent.putExtra(Config.Teamtwo,Teamtwo);
intent.putExtra(Config.Teamtwopts,Teamtwopts);
星触觉(意向);
}
这是我的第二项活动

editTextId = (EditText) findViewById(R.id.editTextId);
        title1ID = (TextView) findViewById(R.id.s_genderID);
        contentID = (TextView) findViewById(R.id.s_nameID);
        dateID = (TextView) findViewById(R.id.teamone);
        teamoneptsID = (TextView) findViewById(R.id.teamonepts);
        teamtwoID = (TextView) findViewById(R.id.teamtwo);
        teamtwoptsID = (TextView) findViewById(R.id.teamtwopts);

        listview = (ListView) findViewById(R.id.listView);

        Typeface font = Typeface.createFromAsset(getAssets(), "arial.ttf");
        title1ID.setTypeface(font);
        contentID.setTypeface(font);
        dateID.setTypeface(font);

        editTextId.setText(id);
        title1ID.setText(titl);
        contentID.setText(cont);
        dateID.setText(date);
        teamoneptsID.setText(teamonepts);
        teamtwoID.setText(teamtwo);
        teamtwoptsID.setText(teamtwopts);
        getResult();

private void getResult() {
        class GetResult extends AsyncTask<Void, Void, String> {
            @Override
            protected void onPreExecute() {
                super.onPreExecute();

            }

            @Override
            protected void onPostExecute(String s) {
                super.onPostExecute(s);
                showResult(s);
            }

            @Override
            protected String doInBackground(Void... params) {
                RequestHandler rh = new RequestHandler();
                String s = rh.sendGetRequestParam(Config.URL_Sport1, id);
                return s;
            }
        }
        GetResult ge = new GetResult();
        ge.execute();
    }

    private void showResult(String json) {
        try {
            JSONObject jsonObject = new JSONObject(json);
            JSONArray result = jsonObject.getJSONArray(Config.TAG_JSON_ARRAY1);
            JSONObject c = result.getJSONObject(0);


        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    private void showResult(){
        JSONObject jsonObject = null;
        ArrayList<HashMap<String,String>> list = new ArrayList<>();
        try {
            jsonObject = new JSONObject(JSON_STRING);
            JSONArray result = jsonObject.getJSONArray(Config.TAG_JSON_ARRAY2);

            for(int i = 0; i<result.length(); i++){
                JSONObject jo = result.getJSONObject(i);
                String teamone = jo.getString(Config.TAG_teamone);
                String teamonepts = jo.getString(Config.TAG_teamonepts);
                String teamtwo = jo.getString(Config.TAG_teamtwo);
                String teamtwopts = jo.getString(Config.TAG_teamtwopts);
                String s_name = jo.getString(Config.TAG_s_name);
                String s_gender = jo.getString(Config.TAG_s_gender);
                HashMap<String,String> match = new HashMap<>();
                match.put(Config.TAG_teamone, teamone);
                match.put(Config.TAG_teamonepts,teamonepts);
                match.put(Config.TAG_teamtwo,teamtwo);
                match.put(Config.TAG_teamtwopts,teamtwopts);
                match.put(Config.TAG_s_name,s_name);
                match.put(Config.TAG_s_gender,s_gender);
                list.add(match);
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

        ListAdapter adapter = new SimpleAdapter(
                Sample.this, list, R.layout.gamesadapterlayout,
                new String[]{Config.TAG_teamone,Config.TAG_teamonepts, Config.TAG_teamtwo, Config.TAG_teamtwopts, Config.TAG_s_name, Config.TAG_s_gender},
                new int[]{ R.id.team1, R.id.score1, R.id.team2, R.id.score2, R.id.Type, R.id.s_gender});
        listview.setAdapter(adapter);
    }
editTextId=(EditText)findViewById(R.id.editTextId);
title1ID=(TextView)findViewById(R.id.s_genderID);
contentID=(TextView)findViewById(R.id.s_nameID);
dateID=(TextView)findViewById(R.id.teamone);
teamoneptsID=(TextView)findViewById(R.id.teamonepts);
teamtwoID=(TextView)findViewById(R.id.teamtwo);
teamtwoptsID=(TextView)findViewById(R.id.teamtwops);
listview=(listview)findViewById(R.id.listview);
Typeface font=Typeface.createFromAsset(getAssets(),“arial.ttf”);
title1ID.setTypeface(字体);
contentID.setTypeface(字体);
dateID.setTypeface(字体);
editTextId.setText(id);
标题1id.setText(标题);
contentID.setText(cont);
dateID.setText(日期);
teamoneptsID.setText(teamonepts);
teamtwoID.setText(teamtwo);
teamtwoptsID.setText(teamtwopts);
getResult();
私有void getResult(){
类GetResult扩展了异步任务{
@凌驾
受保护的void onPreExecute(){
super.onPreExecute();
}
@凌驾
受保护的void onPostExecute(字符串s){
super.onPostExecute(s);
展示结果;;
}
@凌驾
受保护字符串doInBackground(无效…参数){
RequestHandler rh=新的RequestHandler();
字符串s=rh.sendGetRequestParam(Config.URL\u Sport1,id);
返回s;
}
}
GetResult ge=新的GetResult();
ge.execute();
}
私有void showResult(字符串json){
试一试{
JSONObject JSONObject=新的JSONObject(json);
JSONArray result=jsonObject.getJSONArray(Config.TAG_JSON_ARRAY1);
JSONObject c=result.getJSONObject(0);
}捕获(JSONException e){
e、 printStackTrace();
}
}
私有void showResult(){
JSONObject JSONObject=null;
ArrayList=新建ArrayList();
试一试{
jsonObject=新的jsonObject(JSON_字符串);
JSONArray result=jsonObject.getJSONArray(Config.TAG\u JSON\u ARRAY2);

对于(int i=0;i选中此链接我认为该链接,他试图只传递1个结果。我试图检索与我的listview中的单击列表具有相同id的所有内容,先生