Android 未能将意图传递给其他类
后续的代码并没有找到应用程序的下落,我意识到数据到达了ListCat.java类,但是下降了 我的类扩展了片段Android 未能将意图传递给其他类,android,Android,后续的代码并没有找到应用程序的下落,我意识到数据到达了ListCat.java类,但是下降了 我的类扩展了片段 05-13 20:26:00.777 12398-12398/com.learn2crack.tab E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.learn2crack.tab, PID: 12398 java.lang.RuntimeException: Unable to start activity
05-13 20:26:00.777 12398-12398/com.learn2crack.tab E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.learn2crack.tab, PID: 12398
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.learn2crack.tab/com.learn2crack.tab.ListaCat}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:133)
at dalvik.system.NativeStart.main(Native Method)
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.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1937)
at com.learn2crack.tab.ListaCat.onCreate(ListaCat.java:17)
at android.app.Activity.performCreate(Activity.java:5248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:133)
at dalvik.system.NativeStart.main(Native Method)
类Categoria.java
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View categoria = inflater.inflate(R.layout.android_frag, container, false);
final ListView lv = (ListView) categoria.findViewById(R.id.list);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
TextView txt = (TextView) parent.getChildAt(position - lv.getFirstVisiblePosition()).findViewById(R.id.idCAT);
String tagId = txt.getText().toString();
// Starting single contact activity
Intent in = new Intent(getActivity().getApplicationContext(),ListaCat.class);
in.putExtra(TAG_ID, tagId);
startActivity(in);
public View onCreateView(布局、充气机、视图组容器、,
Bundle savedInstanceState){
最终视图类别A=充气机。充气(R.layout.android_frag,容器,假);
最终ListView lv=(ListView)categoria.findViewById(R.id.list);
lv.setOnItemClickListener(新的AdapterView.OnItemClickListener(){
public void onItemClick(AdapterView父级、视图、,
内部位置,长id){
//从选定的ListItem获取值
TextView txt=(TextView)parent.getChildAt(position-lv.getFirstVisiblePosition()).findViewById(R.id.idCAT);
字符串tagId=txt.getText().toString();
//启动单一联系人活动
Intent in=新的Intent(getActivity().getApplicationContext(),ListaCat.class);
in.putExtra(标记ID,标记ID);
星触觉(in);
List_item.xml
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="name"
android:id="@+id/name"
android:textColor="#ff7900"
android:layout_marginLeft="10dp"
android:textSize="20dp"
android:gravity="fill_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/idCAT"
android:visibility="visible" />
</LinearLayout>
android_frag.xml
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/list" />
看起来您正在使用ListActivity
,但不要在布局文件中定义id为@android:id/list
的ListView
。要么这样做,要么使用普通的活动
。有关ListActivity
的更多信息,您的主要错误是
Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
退出getActivity().getApplicationContext()
Intent in = new Intent(getActivity(),ListaCat.class);
in.putExtra(TAG_ID, tagId);
startActivity(in);
检查您的列表是否在中android.R.id.List
(ListView) categoria.findViewById(R.id.list);
你需要从你的项目导入你的R.java,而不是从android.R编辑上面的内容,我在我的android\u frag.xml中有我的id/listAnother查询,现在添加一个ListAdapter,我必须将其更改为extends ListActivity?你的
ListaCat
的onCreate()在哪里
?您是否忘记了setContentView和/或设置了错误的设置?ListCat.javasetContentView(R.layout.listalcales);
那是您的问题。listalcales
中有什么内容?(请编辑您的问题)。您只显示了列表
在android_frag.xml
中,而且……您似乎没有使用它。我有两个问题需要从@id/name和@id/idpost your listalocales.xml中的list_item.xml中获取数据。您似乎在使用ListFragment,但将托管活动声明为ListActivity。Th休息时。