我在我的项目中使用了微调器,以便用户可以从下拉列表中选择数字。我想使用微调器对话框并将其自定义为矩阵,例如1,2,3位于一行4,5,6位于另一行,但用户应该可以选择1或2。这可能吗,以及如何我在布局中使用一个文本框实现了这一点。
答案 0 :(得分:0)
我认为您可以在每个布局的行中使用三个按钮,并在每个按钮中使用setOnClicklistener。
您的适配器中具有如下的customView:
private View getCustomView(int position, ViewGroup viewGroup, int type) {
View view = null;
if (type == OPEN) {
view = mLayoutInflater.inflate(R.layout.spinnerlistcurrencyopen_common, viewGroup, false);
} else if (type == CLOSE) {
view = mLayoutInflater.inflate(R.layout.spinnerlistcurrencyclose_common, viewGroup, false);
}
//find view by id your buttons here
return view;
}
您将在打开模式下使用这样的布局(R.layout.spinnerlistcurrencyopen_common):
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3"
>
<Button android:id="@+id/button1"
...
android:layout_weight="1"/>
<Button android:id="@+id/button2"
...
android:layout_weight="1"/>
<Button
android:id="@+id/button3"
...
android:layout_weight="1"/>
</LinearLayout>