[英]How would I display a text box after an item in my menu is clicked. Android
I am totally new to android development and I am currently working on my first app(will not appear on the market).I am using this app as a learning experience. 我是Android开发的新手,我目前正在开发我的第一个应用程序(不会出现在市场上)。我正在使用这个应用程序作为学习经验。 I have no formal education because I am still in high school.
我没有受过正规教育,因为我还在读高中。 My problem is that after a menu item is clicked, I cant get a text box to appear.
我的问题是,单击一个菜单项后,我无法显示一个文本框。 Also, how would I add more items to my menu?
另外,我如何在菜单中添加更多项目? Thank you(Sorry for my ignorance in android development... ).
谢谢(对不起我在android开发中的无知......)。
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.action_settings:
actset();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void actset() {
// TODO Auto-generated method stub
System.out.println("Developed By Shirwa Mohamed.. ");
}
for the education purpose I'd propose to use Toast
for a lightweight messages: 出于教育目的,我建议使用
Toast
来获取轻量级消息:
Toast.makeText( this, "Developed By Shirwa Mohamed.. ", Toast.LENGTH_LONG).show();
because System.out.println
does not show up on Android screen. 因为
System.out.println
没有显示在Android屏幕上。
If you want more golden stars, you may create full-blown AlertDialog
box: 如果你想要更多的金色星星,你可以创建一个完整的
AlertDialog
框:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Developed by");
builder.setMessage("Shirwa Mohamed");
builder.setPositiveButton( "ok", null);
builder.create().show();
As others have stated, a Toast
object may work for what you want. 正如其他人所说,
Toast
对象可能适合你想要的东西。 It will show a messages for a short amount of time and then disappear. 它会在短时间内显示消息然后消失。 However, if you want more control or would like to display more information then you may consider either an AlertDialog which would show a small window displaying whatever information you wanted.
但是,如果您想要更多控制或想要显示更多信息,那么您可以考虑使用AlertDialog ,它会显示一个显示您想要的任何信息的小窗口。
Or, if you want more functionality, you can create a separate class and declare 或者,如果您想要更多功能,可以创建一个单独的类并声明
android:theme="@android:style/Theme.Dialog"
in the <activity
tag of your manifest
. 在您的
manifest
的<activity
标记中。 This will show a separate Activity
with a Dialog
look. 这将显示一个具有
Dialog
外观的单独Activity
。 Then you just use an Intent
to start that Activity
然后你只需使用一个
Intent
来启动该Activity
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.