- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,我在我的 Android 项目中,收到以下错误。我已经检查了几乎所有类似的问题,我正在尝试在这里使用一些解决方案
RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
但它们似乎不适用。
FATAL EXCEPTION: main
Process: com.spicycurryman.getdisciplined10.app, PID: 1309
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.spicycurryman.getdisciplined10.app/com.spicycurryman.getdisciplined10.app.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:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
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 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:1929)
at com.spicycurryman.getdisciplined10.app.MainActivity.onCreate(MainActivity.java:32)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
位于 android.os.Looper.loop(Looper.java:136) 在 android.app.ActivityThread.main(ActivityThread.java:5017) 在 java.lang.reflect.Method.invokeNative( native 方法) 在 java.lang.reflect.Method.invoke(Method.java:515)
显然,我必须有一个 id 属性为“android.R.id.list”的 ListView,并且我不确定在这种情况下在哪里实现它。
这是我的 MainActivity Java:
package com.spicycurryman.getdisciplined10.app;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.SeekBar.OnSeekBarChangeListener;
import com.triggertrap.seekarc.SeekArc;
import com.triggertrap.seekarc.SeekArc.OnSeekArcChangeListener;
public class MainActivity extends ListActivity {
private SeekArc mSeekArc;
private SeekBar mRotation;
private SeekBar mStartAngle;
private SeekBar mSweepAngle;
private SeekBar mArcWidth;
private SeekBar mProgressWidth;
private CheckBox mRoundedEdges;
private CheckBox mTouchInside;
private CheckBox mClockwise;
private TextView mSeekArcProgress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSeekArc = (SeekArc) findViewById(R.id.seekArc);
mSeekArcProgress = (TextView) findViewById(R.id.seekArcProgress);
mRotation = (SeekBar) findViewById(R.id.rotation);
mStartAngle = (SeekBar) findViewById(R.id.startAngle);
mSweepAngle = (SeekBar) findViewById(R.id.sweepAngle);
mArcWidth = (SeekBar) findViewById(R.id.arcWidth);
mProgressWidth = (SeekBar) findViewById(R.id.progressWidth);
mRoundedEdges = (CheckBox) findViewById(R.id.roundedEdges);
mTouchInside = (CheckBox) findViewById(R.id.touchInside);
mClockwise = (CheckBox) findViewById(R.id.clockwise);
mRotation.setProgress(mSeekArc.getArcRotation());
mStartAngle.setProgress(mSeekArc.getStartAngle());
mSweepAngle.setProgress(mSeekArc.getSweepAngle());
mArcWidth.setProgress(mSeekArc.getArcWidth());
mProgressWidth.setProgress(mSeekArc.getProgressWidth());
mSeekArc.setOnSeekArcChangeListener(new OnSeekArcChangeListener() {
@Override
public void onStopTrackingTouch(SeekArc seekArc) {
}
@Override
public void onStartTrackingTouch(SeekArc seekArc) {
}
@Override
public void onProgressChanged(SeekArc seekArc, int progress,
boolean fromUser) {
mSeekArcProgress.setText(String.valueOf(progress));
}
});
mRotation.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar arg0) {
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
}
@Override
public void onProgressChanged(SeekBar view, int progress, boolean fromUser) {
mSeekArc.setArcRotation(progress);
mSeekArc.invalidate();
}
});
mStartAngle.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar arg0) {
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
}
@Override
public void onProgressChanged(SeekBar view, int progress, boolean fromUser) {
mSeekArc.setStartAngle(progress);
mSeekArc.invalidate();
}
});
mSweepAngle.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar arg0) {
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
}
@Override
public void onProgressChanged(SeekBar view, int progress, boolean fromUser) {
mSeekArc.setSweepAngle(progress);
mSeekArc.invalidate();
}
});
mArcWidth.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar arg0) {
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
}
@Override
public void onProgressChanged(SeekBar view, int progress, boolean fromUser) {
mSeekArc.setArcWidth(progress);
mSeekArc.invalidate();
}
});
mProgressWidth.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar arg0) {
}
@Override
public void onStartTrackingTouch(SeekBar arg0) {
}
@Override
public void onProgressChanged(SeekBar view, int progress, boolean fromUser) {
mSeekArc.setProgressWidth(progress);
mSeekArc.invalidate();
}
});
mRoundedEdges.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
mSeekArc.setRoundedEdges(isChecked);
mSeekArc.invalidate();
}
});
mTouchInside.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
mSeekArc.setTouchInSide(isChecked);
}
});
mClockwise.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
mSeekArc.setClockwise(isChecked);
mSeekArc.invalidate();
}
});
}
}
这是我对应于Java的activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:seekarc="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
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=".MainActivity" >
<FrameLayout
android:id="@+id/seekArcContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<com.triggertrap.seekarc.SeekArc
android:id="@+id/seekArc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="30dp"
seekarc:rotation="180"
seekarc:startAngle="30"
seekarc:sweepAngle="300"
seekarc:touchInside="true"
seekarc:arcColor="#ff2ca3cc"
seekarc:progressColor="#ffcc2d2a"/>
<TextView
android:id="@+id/seekArcProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textSize="40sp" />
</FrameLayout>
<include
android:id="@+id/controls"
layout="@layout/controls" />
</LinearLayout>
我不确定如何解释该错误,因为我的 xml 文件不需要添加所要求的内容,对吗?
最佳答案
您的activity_main.xml
必须有一个ID为@android:id/list
的ListView
引用文档
ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list" (or list if it's in code)
但是在你的代码中你在哪里有setListAdapter
?您也可以扩展 Activity
而不是 ListAcitvity
关于java - 尽管有 xml,但仍因缺少 ListView 而收到 RuntimeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24211794/
我正在尝试在 map 上绘制一些疾病事件数据的位置。 我用它来导入数据: ByTown% addProviderTiles("CartoDB.Positron")%>% addPolygons
我有一个文件调用 find.js,我使用 node find.js 运行,我的节点是版本 10 我不知道为什么我无法使用 async await。 const axios = require("axi
我有一个项目作为引用添加到 System.Web。 但是,它似乎无法获取 HttpContext。这样做: Imports System.Web _ApplicationBase = HttpCont
在互联网上找到这段代码,出于某种原因它缺少 while 循环逻辑“while(i....)”,虽然我找到了 PigLatin* 问题的其他可行解决方案,但我真的很想了解这个正在工作。 *PigLati
我工作了一整天来运行 Xampp 并在其上安装 TYPO3。现在我登录到后端,但没有显示许多管理模块,例如模板、访问等。 - 一定是我做错了什么,但我不知道。 these are the module
你好 我有编译这个问题 \begin{equation} J = \sum_{j=1}^{C} \end{equation} 我不断收到错误 missing $ inserted 这很奇怪,因
我正在尝试使用 SQLite CLI,但无法获得 generate_series功能来工作。我可以按照文档中的建议使用递归 CTE 对其进行模拟,但我似乎无法获得该链接中的任何示例。这是我的 sess
我目前正在开发我想要的软件,而软件正在安装,它可以在后台为软件创建 native 图像。 我正在考虑使用 NGEN 并将进程优先级设置为低,因为我不希望它消耗 100% CPU。但是我发现我的计算机上
我想使用 Xcodes Instruments 进行 UI 自动化测试。但似乎缺少“自动化”。我怎样才能添加这个? 最佳答案 如果您想使用自动化仪器,请使用 Xcode 7.3。 Apple 在 Xc
我目前在 JS 开发中迈出了一小步,并编写了以下链接添加器: const button = document.getElementById('button') const listdiv = docu
此代码有什么问题: NSError *error = nil; [SFHFKeychainUtils deleteItemForUsername:@"IAPNoob01" andServiceName
出于某种原因,在安装和配置(我认为)一切之后,com.adobe.utils.AGALMiniAssembler 不见了,其他一切正常。 我认为我已尽一切努力让孵化器正常工作,但显然我错过了一步。 如
我有一个名为 new 的方法。调用 new 时,我传递了一个参数,但是当我运行应用程序时,出现没有参数或参数为空的错误。 StepReader.pm package StepReader; use s
安装 gtk 1.2(包名 gtk1)和 macports chokes 在最终的 make 中,在 libintl.h 的第 440 行。 extern locale_t libintl_newlo
我用按钮创建表格。 这是javascript代码: function layersListTable(layers) { var content =''; $.each($(layer
我在使用此 javascript 时遇到此错误,任何人都可以帮我弄清楚我做错了什么吗? $(this).prepend('Check availability »'); 它给我错误 mis
我有一个独立的工具链 NDK13b、api19、llvm 3.8 编译器、arm 32 位、带有 libcpp(llvm C++ 库) 我想避免依赖 libgcc,所以我构建了 compiler-rt
我按照一些教程使用 phonegap 的条形码扫描器插件。但是当我从现有源创建一个新的 android 项目来创建条码库时 (step 6 in this page)我收到错误:“AndroidMan
我现在尝试在 Eclipse 中打开我的布局 xml 文件。我只得到错误 No XML content. Please add a root view or layout to your docume
我的 android-sdk-windows\tools 目录中缺少层次结构查看器工具。 工具链接: http://developer.android.com/guide/developing/too
我是一名优秀的程序员,十分优秀!