layout.xml 文件有按钮,我不知道如何链接每个按钮以打开新的首选项屏幕
layout.xml 文件有按钮,我不知道如何链接每个按钮以打开新的首选项屏幕。
希望重新排列我的应用程序,目前都是首选项屏幕,想对其进行更改以稍微修改 UI,以便在主页上有按钮,每个按钮都会打开一个我已经设置的新首选项屏幕,任何建议,我都可以似乎不知道如何打开已经制作的偏好屏幕。
layout.xml file has button, I can't figure out how to link each button to open a new preference screen.
looking to rearrange my app, currently it's all preference screen, wantedto change it to revamp the UI a little to have buttons on the main page, and each one will open a new preference screen that I already have set up, any advice, I can't seem to figure out how to have it just open that already made preference scree.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于从主屏幕转到另一个屏幕之类的事情,我会做类似这样的事情:
地板是一个按钮图像,它会启动新的活动,当单击它时会启动 WheelDemo 并转到该活动的新屏幕。只要确保每项活动都已在您的清单中注册即可。
For something like going to another screen from a home screen, i'll do somethingl ike this:
floor is a button image, it starts the new activity, WheelDemo when it is clicked on and goes to a new screen for that activity. Jut make sure each activity is registered in your manifest.
首先,如何在单击按钮时执行一些 Java 代码:
android:onClick="onSomethingDescriptiveClick"
,添加一个方法public void onSomethingDescriptiveClick( View caller) {}
当您点击正在运行的应用程序中的按钮时,将执行此方法。将
SomethingDescriptive
替换为呃,描述性的东西。例如,如果您的按钮显示“Preferences”,则回调方法可能是onPreferencesClick
。接下来,请查阅此内容以了解如何开始新活动:http:// developer.android.com/guide/topics/fundamentals/activities.html#StartingAnActivity
First, how to get some Java code executed when you click on a button:
android:onClick="onSomethingDescriptiveClick"
public void onSomethingDescriptiveClick(View caller) {}
This method will be executed, when you click on a button in running app. Replace
SomethingDescriptive
with, uh, something descriptive. For example, if your button says "Preferences", the callback method could beonPreferencesClick
.Next, consult this to see how to start a new activity: http://developer.android.com/guide/topics/fundamentals/activities.html#StartingAnActivity
我使用了普通的 EditTextPreference,但处理了 onPreferenceClick 以取消对话框并捕获单击。
I used a normal EditTextPreference but handled onPreferenceClick to cancel the dialog and catch the click.