本文介绍了微调在Android的列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个视图完全一样。
Hi i wanted to create a view exactly like this.
在列表视图项被点击时,无线电按钮的微调应该打开。
Once the item in a list view is clicked, a spinner with radio buttons should open.
推荐答案
如果你想显示一个微调框为每个列表项单击ListView中。它可能与 AlertDialog
。
If you want to display a spinner for every list item clicked in ListView. Its possible with AlertDialog
.
尝试使用的
和尝试此块
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0,
View arg1, int position, long arg3)
{
AlertDialogView();
}
}
而$ C $下的 AlertDialogView()会是这样
private void AlertDialogView()
{
final CharSequence[] items = {"15 secs", "30 secs", "1 min", "2 mins"};
AlertDialog.Builder builder = new AlertDialog.Builder(ShowDialog.this);
builder.setTitle("Alert Dialog with ListView and Radio button");
builder.setIcon(R.drawable.icon);
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
builder.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Toast.makeText(ShowDialog.this, "Success", Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Toast.makeText(ShowDialog.this, "Fail", Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
alert.show();
}
这篇关于微调在Android的列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!