我希望当前列表视图在当前列表视图中按下某个项目时打开新的列表视图。 [英] I want my current listview to open a new listview when an item is pressed in current listview.

查看:89
本文介绍了我希望当前列表视图在当前列表视图中按下某个项目时打开新的列表视图。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我用来运行应用程序。崩溃。可能是什么问题?任何人都可以帮助我。我已经使用当前活动的onClickItem方法调用了第二个活动但是它没有工作



我尝试过:



MainActivity



包com.example.brandonmain.listviewexample1;



import android.app.ListActivity;

import android.content.Intent;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android .view.View;

import android.widget.ListView;

import android.widget.SectionIndexer;

import android.widget.SimpleAdapter;

导入android.widget.TextView;

导入android.widget.Toast;



import java.util .ArrayList;

import java.util.Dictionary;

import java.util.Enumeration;

import java.util.HashMap;

imp ort java.util.Iterator;

import java.util.List;

import java.util.Map;

import java.util。 TreeMap;



导入静态android.R.attr.name;



公共类MainActivity扩展ListActivity {



@Override

protected void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);



ListView resultsListView =(ListView)findViewById(R.id.results_listview);



HashMap< String,String> nameAddresses = new HashMap<>();

nameAddresses.put(主席Seceretery,7楼);

nameAddresses.put(公司事务部) ,6楼);

nameAddresses.put(导演(技术)秘书处,5楼);

nameAddresses.put(操作, 5楼);

nameAddresses.put(紧急控制室,5楼);

nameAddresses.put(企业风险管理,5楼);

nameAddresses.put(商业计划,5楼);

nameAddresses.put(董事(财务)秘书处,4rth Floor );

nameAddresses.put(Finance,4rth Floor);

nameAddresses.put(DIRECTOR(PERSONNEL)SECRETARIAT,3rd Floor);

nameAddresses.put(人员,3楼);

nameAddresses.put(ED(LAW)& PLO,3rd Floor);

nameAddresses.put(业务规划,3楼);

nameAddresses.put(转型监控办公室,3楼);

nameAddresses.put(Vigilance,2nd楼层);

nameAddresses.put(管理,二楼);

nameAddresses.put(Parliament Cell,2nd Floor); < br $>
nameAddresses.put(企业规划,二楼);

nameAddresses.put(煤炭进口集团,二楼);

nameAddresses.put(导演(P& SP)秘书处,1楼);

nameAddresses.put(商业计划,1楼);

nameAddresses.put(C& IT,1楼);

nameAddresses.put(医疗与健康服务,1楼);

nameAddresses.put(Director( RM& L)秘书处,1楼);

nameAddresses.put(CRMG,1楼);

nameAddresses.put(ICVL ,1楼);

nameAddresses.put(O / o ED(森林),1楼);

nameAddresses.put(接待) ,底层);

nameAddresses.put(印度国家银行,底层);

nameAddresses.put(图书馆,地面楼层);

nameAddresses.put(地下室,底层);

nameAddresses.put(Administration-Kaushambi,一楼);

Map< String,String> treeMap = new TreeMap< String,String>(nameAddresses);





列表< HashMap< String,String>> listItems = new ArrayList<>();

SimpleAdapter适配器= new SimpleAdapter(this,listItems,R.layout.list_item,

new String [] {First Line,Second Line},

new int [] {R.id.text1,R.id.text2});





Iterator it = treeMap.entrySet()。iterator( );

while(it.hasNext()){

HashMap< String,String> resultsMap = new HashMap<>();

Map.Entry pair =(Map.Entry)it.next();

resultsMap.put(First Line ,pair.getKey()。toString());

resultsMap.put(Second Line,pair.getValue()。toString());

listItems。添加(resultsMap);

}

resultsListView.setAdapter(适配器);

}

@Override

public void onListItemClick(ListView l,View view,int position,long id)

{

super.onListItemClick(l,view,position,id );



if(position == 0){

Intent intent = new Intent(this,Adminstrative.class);

startActivity(意图);

}

}











}



Mainxml

<?xml version =1.0encoding =ut f-8?>

< RelativeLayout xmlns:android =http://schemas.android.com/apk/res/android

xmlns:tools =http://schemas.android.com/tools

android:id =@ + id / activity_main

android:layout_width =match_parent

android:layout_height =match_parent

android:paddingBottom =@ dimen / activity_vertical_margin

android:paddingLeft =@ dimen / activity_horizo​​ntal_margin

android:paddingRight =@ dimen / activity_horizo​​ntal_margin

android:paddingTop =@ dimen / activity_vertical_margin

tools:context =com。 example.brandonmain.listviewexample1.MainActivity>



< ListView

android:id =@ + id / results_listview

android:layout_width =match_parent

android:layout_height =wrap_content

android:fastScrollEnabled =true

/>





我希望我当前的列表视图在当前ListView中按下某个项目时打开一个新的列表视图。



MainActivity



package com.example.brandonmain.listviewexample1;



import android.app.ListActivity;

import android.content.Intent;

导入android.support.v7.app.AppCompatActivity;

导入android.os.Bundle;

导入android.view.View;

import android.widget.ListView;

import android.widget.SectionIndexer;

import android.widget.SimpleAdapter;

import android.widget.TextView;

import android.widget.Toast;



import java.util.ArrayList;

import java.util.Dictionary;

import java.util.Enumeration;

import java.util.HashMap;

import java .util.Iterator;

import java.util.List;

import java.util.Map;

import java.util.TreeMap;



import s tatic android.R.attr.name;



公共类MainActivity扩展ListActivity {



@Override

protected void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);



ListView resultsListView =(ListView)findViewById(R.id.results_listview);



HashMap< String,String> nameAddresses = new HashMap<>();

nameAddresses.put(主席Seceretery,7楼);

nameAddresses.put(公司事务部) ,6楼);

nameAddresses.put(导演(技术)秘书处,5楼);

nameAddresses.put(操作, 5楼);

nameAddresses.put(紧急控制室,5楼);

nameAddresses.put(企业风险管理,5楼);

nameAddresses.put(商业计划,5楼);

nameAddresses.put(董事(财务)秘书处,4rth Floor );

nameAddresses.put(Finance,4rth Floor);

nameAddresses.put(DIRECTOR(PERSONNEL)SECRETARIAT,3rd Floor);

nameAddresses.put(人员,3楼);

nameAddresses.put(ED(LAW)& PLO,3rd Floor);

nameAddresses.put(业务规划,3楼);

nameAddresses.put(转型监控办公室,3楼);

nameAddresses.put(Vigilance,2nd楼层);

nameAddresses.put(管理,二楼);

nameAddresses.put(Parliament Cell,2nd Floor); < br $>
nameAddresses.put(企业规划,二楼);

nameAddresses.put(煤炭进口集团,二楼);

nameAddresses.put(导演(P& SP)秘书处,1楼);

nameAddresses.put(商业计划,1楼);

nameAddresses.put(C& IT,1楼);

nameAddresses.put(医疗与健康服务,1楼);

nameAddresses.put(Director( RM& L)秘书处,1楼);

nameAddresses.put(CRMG,1楼);

nameAddresses.put(ICVL ,1楼);

nameAddresses.put(O / o ED(森林),1楼);

nameAddresses.put(接待) ,底层);

nameAddresses.put(印度国家银行,底层);

nameAddresses.put(图书馆,地面楼层);

nameAddresses.put(地下室,底层);

nameAddresses.put(Administration-Kaushambi,一楼);

Map< String,String> treeMap = new TreeMap< String,String>(nameAddresses);





列表< HashMap< String,String>> listItems = new ArrayList<>();

SimpleAdapter适配器= new SimpleAdapter(this,listItems,R.layout.list_item,

new String [] {First Line,Second Line},

new int [] {R.id.text1,R.id.text2});





Iterator it = treeMap.entrySet()。iterator( );

while(it.hasNext()){

HashMap< String,String> resultsMap = new HashMap<>();

Map.Entry pair =(Map.Entry)it.next();

resultsMap.put(First Line ,pair.getKey()。toString());

resultsMap.put(Second Line,pair.getValue()。toString());

listItems。添加(resultsMap);

}

resultsListView.setAdapter(适配器);

}

@Override

public void onListItemClick(ListView l,View view,int position,long id)

{

super.onListItemClick(l,view,position,id );



if(position == 0){

Intent intent = new Intent(this,Adminstrative.class);

startActivity(意图);

}

}











}



Mainxml

<?xml version =1.0encoding =ut f-8?>

< RelativeLayout xmlns:android =http://schemas.android.com/apk/res/android

xmlns:tools =http://schemas.android.com/tools

android:id =@ + id / activity_main

android:layout_width =match_parent

android:layout_height =match_parent

android:paddingBottom =@ dimen / activity_vertical_margin

android:paddingLeft =@ dimen / activity_horizo​​ntal_margin

android:paddingRight =@ dimen / activity_horizo​​ntal_margin

android:paddingTop =@ dimen / activity_vertical_margin

tools:context =com。 example.brandonmain.listviewexample1.MainActivity>



< ListView

android:id =@ + id / results_listview

android:layout_width =match_parent

android:layout_height =wrap_content

android:fastScrollEnabled =true

/>



第二项活动: package com.example.brandonmain.listviewexample1;



import android.support.v7.app.AppCompatActivity;

import android.os.Bundle ;

导入android.widget.ListView;

导入android.widget.SimpleAdapter;



导入java。 util.ArrayList;

import java.util.HashMap;

import java.util.Iterator;

import java.util.List;

import java.util.Map;

import java.util.TreeMap;



公共类Adminstrative扩展AppCompatActivity {$ / $


@Override

protected void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_adminstrative);

ListView resultsListView1 =(ListView)findViewById(R.id.administrative);

HashMap<字符串,字符串> nameAddresses1 = new HashMap<>();

nameAddresses1.put(xyz,7th floor);



Map<字符串,字符串> treeMap1 = new TreeMap< String,String>(nameAddresses1);





List< HashMap< String,String>> listItems1 = new ArrayList<>();

SimpleAdapter adapter1 = new SimpleAdapter(this,listItems1,R.layout.list_item,

new String [] {First Line ,第二行},

new int [] {R.id.text1,R.id.text2});





Iterator it = treeMap1.entrySet()。iterator();

while(it.hasNext()){

HashMap< String ,String> resultsMap1 = new HashMap<>();

Map.Entry pair =(Map.Entry)it.next();

resultsMap1.put(First Line ,pair.getKey()。toString());

resultsMap1.put(Second Line,pair.getValue()。toString());

listItems1。 add(resultsMap1);

}

resultsListView1.setAdapter(adapter1);



}

}



administrative.xml



<?xml version =1.0编码=utf-8?>

< LinearLayout xmlns:android =http://schemas.android.com/apk/res/android

xmlns :app =http://schemas.android.com/apk/res-auto

xmlns:tools =http://schemas.android.com/tools

android:layout_width =match_parent

android:layout_height =match_parent

tools:context =com.example.brandonmain.listviewexample1.Adminstrative>





< ListView

android:layout_width =match_parent

android:layout_height =match_parent

android:id =@ + id / adminstrative

android:fastScrollEnabled =true/>

< / LinearLayout

解决方案

Logcat



java.lang.RuntimeException:无法启动活动ComponentInfo {com.example .brandonmain.listviewexample1 / com.example.brandonmain.listviewexample1.MainActivity}:java.lang.RuntimeException:你的内容必须有一个ListView,其id属性为''android.R.id.list''

在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2581)

在android.app.ActivityThread.handleLaunchA活动(ActivityThread.java:2647)

在android.app.ActivityThread.-wrap11(ActivityThread.java)

在android.app.ActivityThread


H.handleMessage(ActivityThread.java:1502)

在android.os.Handler.dispatchMessage(Handler.java:111)

在android.os .Looper.loop(Looper.java:207)

在android.app.ActivityThread.main(ActivityThread.java:5763)

在java.lang.reflect.Method 。调用(本机方法)

在com.android.internal.os.ZygoteInit


MethodAndArgsCaller.run(ZygoteInit.java:789)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

引起:java.lang.RuntimeException:您的内容必须有一个List属性,其id属性为'' android.R.id.list''

在android.app.ListActivity.onContentChanged(ListActivity.java:243)

at com.android.internal.policy.PhoneWindow .setContentView(PhoneWindow.java:418)

在android.app.Activity.setContentView(Activity.java:2190)

at com.example.brandonmain.listviewexample1.MainActivity.onCreate(MainActivity.java:30)

在android.app.Activity.performCreate(Activity.java:6270)

在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)

在android.app .ActivityThread.performLaunchActivity(ActivityThread.java:2534)

在android.app.ActivityThread.handleL aunchActivity(ActivityThread.java:2647) 

在android.app.ActivityThread.-wrap11(ActivityThread.java) 

在android.app.ActivityThread

Every time I use to run the application.It crashes.What could be the issue??can anyone help me out.I have called 2nd activity using current activity''s onClickItem method but it''s not working

What I have tried:

MainActivity

package com.example.brandonmain.listviewexample1;

import android.app.ListActivity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SectionIndexer;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import static android.R.attr.name;

public class MainActivity extends ListActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ListView resultsListView = (ListView) findViewById(R.id.results_listview);

HashMap<String, String> nameAddresses = new HashMap<>();
nameAddresses.put("Chairman Seceretery", "7th floor");
nameAddresses.put("Corporate Affairs Division", "6th floor");
nameAddresses.put("Director(Technical) Secretariat", "5th Floor");
nameAddresses.put("Operations", "5th Floor");
nameAddresses.put("Emergency Control room", "5th Floor");
nameAddresses.put("Enterprise risk management", "5th Floor");
nameAddresses.put("Business Planning", "5th Floor");
nameAddresses.put("Director(Finance) Secretariat", "4rth Floor");
nameAddresses.put("Finance", "4rth Floor");
nameAddresses.put("DIRECTOR (PERSONNEL) SECRETARIAT", "3rd Floor");
nameAddresses.put("Personnel", "3rd Floor");
nameAddresses.put("ED(LAW)& PLO", "3rd Floor");
nameAddresses.put("Business Planning", "3rd Floor");
nameAddresses.put("Transformation monitoring office", "3rd Floor");
nameAddresses.put("Vigilance", "2nd Floor");
nameAddresses.put("Administration", "2nd Floor");
nameAddresses.put("Parliament Cell", "2nd Floor");
nameAddresses.put("Corporate Planning", "2nd Floor");
nameAddresses.put("Coal Import Group", "2nd Floor");
nameAddresses.put("Director(P&SP) Secretariat", "1st Floor");
nameAddresses.put("Business Planning", "1st Floor");
nameAddresses.put("C & IT", "1st Floor");
nameAddresses.put("Medical & Health Service", "1st Floor");
nameAddresses.put("Director(RM&L) Secretariat", "1st Floor");
nameAddresses.put("CRMG", "1st Floor");
nameAddresses.put("ICVL", "1st Floor");
nameAddresses.put("O/o ED(Forest)", "1st Floor");
nameAddresses.put("Reception", "Ground Floor");
nameAddresses.put("State Bank Of India", "Ground Floor");
nameAddresses.put("Library", "Ground Floor");
nameAddresses.put("Basement", "Ground Floor");
nameAddresses.put("Administration-Kaushambi ", "Ground Floor");
Map<String, String> treeMap = new TreeMap<String, String>(nameAddresses);


List<HashMap<String, String>> listItems = new ArrayList<>();
SimpleAdapter adapter = new SimpleAdapter(this, listItems, R.layout.list_item,
new String[]{"First Line", "Second Line"},
new int[]{R.id.text1, R.id.text2});


Iterator it = treeMap.entrySet().iterator();
while (it.hasNext()) {
HashMap<String, String> resultsMap = new HashMap<>();
Map.Entry pair = (Map.Entry) it.next();
resultsMap.put("First Line", pair.getKey().toString());
resultsMap.put("Second Line", pair.getValue().toString());
listItems.add(resultsMap);
}
resultsListView.setAdapter(adapter);
}
@Override
public void onListItemClick(ListView l, View view, int position, long id)
{
super.onListItemClick(l, view, position, id);

if (position == 0) {
Intent intent = new Intent(this, Adminstrative.class);
startActivity(intent);
}
}





}

Mainxml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.brandonmain.listviewexample1.MainActivity">

<ListView
android:id="@+id/results_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fastScrollEnabled="true"
/>


I want my current listview to open a new listview when an item is pressed in current ListView.

MainActivity

package com.example.brandonmain.listviewexample1;

import android.app.ListActivity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SectionIndexer;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import static android.R.attr.name;

public class MainActivity extends ListActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ListView resultsListView = (ListView) findViewById(R.id.results_listview);

HashMap<String, String> nameAddresses = new HashMap<>();
nameAddresses.put("Chairman Seceretery", "7th floor");
nameAddresses.put("Corporate Affairs Division", "6th floor");
nameAddresses.put("Director(Technical) Secretariat", "5th Floor");
nameAddresses.put("Operations", "5th Floor");
nameAddresses.put("Emergency Control room", "5th Floor");
nameAddresses.put("Enterprise risk management", "5th Floor");
nameAddresses.put("Business Planning", "5th Floor");
nameAddresses.put("Director(Finance) Secretariat", "4rth Floor");
nameAddresses.put("Finance", "4rth Floor");
nameAddresses.put("DIRECTOR (PERSONNEL) SECRETARIAT", "3rd Floor");
nameAddresses.put("Personnel", "3rd Floor");
nameAddresses.put("ED(LAW)& PLO", "3rd Floor");
nameAddresses.put("Business Planning", "3rd Floor");
nameAddresses.put("Transformation monitoring office", "3rd Floor");
nameAddresses.put("Vigilance", "2nd Floor");
nameAddresses.put("Administration", "2nd Floor");
nameAddresses.put("Parliament Cell", "2nd Floor");
nameAddresses.put("Corporate Planning", "2nd Floor");
nameAddresses.put("Coal Import Group", "2nd Floor");
nameAddresses.put("Director(P&SP) Secretariat", "1st Floor");
nameAddresses.put("Business Planning", "1st Floor");
nameAddresses.put("C & IT", "1st Floor");
nameAddresses.put("Medical & Health Service", "1st Floor");
nameAddresses.put("Director(RM&L) Secretariat", "1st Floor");
nameAddresses.put("CRMG", "1st Floor");
nameAddresses.put("ICVL", "1st Floor");
nameAddresses.put("O/o ED(Forest)", "1st Floor");
nameAddresses.put("Reception", "Ground Floor");
nameAddresses.put("State Bank Of India", "Ground Floor");
nameAddresses.put("Library", "Ground Floor");
nameAddresses.put("Basement", "Ground Floor");
nameAddresses.put("Administration-Kaushambi ", "Ground Floor");
Map<String, String> treeMap = new TreeMap<String, String>(nameAddresses);


List<HashMap<String, String>> listItems = new ArrayList<>();
SimpleAdapter adapter = new SimpleAdapter(this, listItems, R.layout.list_item,
new String[]{"First Line", "Second Line"},
new int[]{R.id.text1, R.id.text2});


Iterator it = treeMap.entrySet().iterator();
while (it.hasNext()) {
HashMap<String, String> resultsMap = new HashMap<>();
Map.Entry pair = (Map.Entry) it.next();
resultsMap.put("First Line", pair.getKey().toString());
resultsMap.put("Second Line", pair.getValue().toString());
listItems.add(resultsMap);
}
resultsListView.setAdapter(adapter);
}
@Override
public void onListItemClick(ListView l, View view, int position, long id)
{
super.onListItemClick(l, view, position, id);

if (position == 0) {
Intent intent = new Intent(this, Adminstrative.class);
startActivity(intent);
}
}





}

Mainxml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.brandonmain.listviewexample1.MainActivity">

<ListView
android:id="@+id/results_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fastScrollEnabled="true"
/>

2nd Activity: package com.example.brandonmain.listviewexample1;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class Adminstrative extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_adminstrative);
ListView resultsListView1 = (ListView) findViewById(R.id.administrative);
HashMap<String, String> nameAddresses1 = new HashMap<>();
nameAddresses1.put("xyz", "7th floor");

Map<String, String> treeMap1 = new TreeMap<String, String>(nameAddresses1);


List<HashMap<String, String>> listItems1 = new ArrayList<>();
SimpleAdapter adapter1 = new SimpleAdapter(this, listItems1, R.layout.list_item,
new String[]{"First Line", "Second Line"},
new int[]{R.id.text1, R.id.text2});


Iterator it = treeMap1.entrySet().iterator();
while (it.hasNext()) {
HashMap<String, String> resultsMap1 = new HashMap<>();
Map.Entry pair = (Map.Entry) it.next();
resultsMap1.put("First Line", pair.getKey().toString());
resultsMap1.put("Second Line", pair.getValue().toString());
listItems1.add(resultsMap1);
}
resultsListView1.setAdapter(adapter1);

}
}

administrative.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.brandonmain.listviewexample1.Adminstrative">


<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/adminstrative"
android:fastScrollEnabled="true"/>
</LinearLayout

解决方案

Logcat

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.brandonmain.listviewexample1/com.example.brandonmain.listviewexample1.MainActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is ''android.R.id.list''
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2581)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread


H.handleMessage(ActivityThread.java:1502)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5763)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit


MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is ''android.R.id.list''
at android.app.ListActivity.onContentChanged(ListActivity.java:243)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:418)
at android.app.Activity.setContentView(Activity.java:2190)
at com.example.brandonmain.listviewexample1.MainActivity.onCreate(MainActivity.java:30)
at android.app.Activity.performCreate(Activity.java:6270)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread


这篇关于我希望当前列表视图在当前列表视图中按下某个项目时打开新的列表视图。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆