English 中文(简体)
将按钮添加到首选项屏幕底部
原标题:Add a button to the bottom of Preferences Screen
最佳回答

您必须包含一个 ListView 和 id < codeandroid: id/ list , 就像您所联系到的问题( 见 < a href=" https:// stackoverflow.com/ a/ 3026922/831918 > Answer ) 中所说的那样 。

从您的和机器人布局文件( R. Layout.Preferences) 中删除您的 , 并将其放入它的位置 。

<ListView android:id="@android:id/list" 
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" />

这应该能解决你现在的问题

From the LogCat you posted: Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is android.R.id.list


编辑: 只需对 ListView 上的 id 属性进行一些澄清。 从 < a href=" http:// developmenter.android.com/guide/topics/ ui/ declaring-layout.html#id" rel= “ nofollow norefererr" >Android XML 版式 。

在 XML 标记内, ID 的语法是 :

和机器人:id="id/我的按钮"

字符串开头的 at- symbol (@) 表示 XML 解析器应该解析和扩展其余的 ID 字符串, 并将其识别为 ID 资源。 附加符号 (+) 意味着这是一个必须创建并添加到我们资源中的新资源名称( 在 R.java 文件中 ) 。 Android 框架提供了一些其它的 ID 资源 。 在引用 Android 资源标识时, 您不需要 plus- symbol, 但必须添加该和机器人包的命名空间, 如 :

和机器人:id="@android:id/空"

和 roid 包件命名空间已经到位, 我们现在重新引用来自 android. R 资源类的 ID, 而不是本地资源类 。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签