欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > Android >内容正文

Android

android combobox控件,Android中的组合框

发布时间:2024/1/23 Android 37 豆豆
生活随笔 收集整理的这篇文章主要介绍了 android combobox控件,Android中的组合框 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

在android组合框中称为微调框.然而,gnugu已经在自己的博客中发布了自己的一个组合框的实现.

http://www.gnugu.com/node/57

以下是旋转器的一个简单示例.

首先,用这样的方式编辑你的XML代码

Spinner android:id="@+id/Spinner01"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

您的java代码应该包括这样的东西,这些选项非常直观.如果你正在使用eclipse,它会建议你一些选择

public class SpinnerExample extends Activity {

private String array_spinner[];

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

// Here come all the options that you wish to show depending on the

// size of the array.

array_spinner=new String[5];

array_spinner[0]="option 1";

array_spinner[1]="option 2";

array_spinner[2]="option 3";

array_spinner[3]="option 4";

array_spinner[4]="option 5";

Spinner s = (Spinner) findViewById(R.id.Spinner01);

ArrayAdapter adapter = new ArrayAdapter(this,

android.R.layout.simple_spinner_item, array_spinner);

s.setAdapter(adapter);

}

}

总结

以上是生活随笔为你收集整理的android combobox控件,Android中的组合框的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。