我有关于微调器的问题,在网上找不到有关如何操作的信息.
我的应用程序中有一个微调器,区域选择即西南,东南.
我希望微调器可用于第二个微调器的选择取决于第一个微调器的选择.即,当用户选择西南时,第二个旋转器上的选择将是查尔斯湖,爱荷华州,亚瑟湖等.当用户选择东南时,第二个旋转器的选择将是Gretna,New Orleans,Luling等.
我该怎么做呢?
例子将不胜感激!
谢谢!
我有包含微调器、图像和 TextView 的 ListView。在此 ListView 上方,我有一个 EditText,用户可以在其中键入所需的项目名称,并且所有相关项目都已显示在 ListView 中。我的代码一直工作到这里,但问题是当我尝试删除应用程序刚刚崩溃的最后一个字符时。我认为列表视图没有正确刷新。我已经搜索了很多答案,但没有发现与我的问题相关的任何内容,所以请帮助我解决该应用程序 carsh 问题。
这是我在从 BaseAdapter 扩展的 LazyAdapter 中的 getFilter 代码
@SuppressLint("DefaultLocale")
public android.widget.Filter getFilter() {
return new android.widget.Filter() {
@SuppressLint("DefaultLocale")
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults Result = new FilterResults();
// if constraint is empty return the original names
if (TextUtils.isEmpty(constraint)){
//Result.values = storedata;
Result.count = listDetails.size();
return Result;
}
ArrayList<items> Filtered_Names = new ArrayList<items>();
String filterString = constraint.toString().toLowerCase();
String filterableString;
for(int i = 0; i<listDetails.size(); i++){
items searchdata = listDetails.get(i); …Run Code Online (Sandbox Code Playgroud) 我正在使用我正在使用的演示应用程序Spinner并且具有类似黑色的背景颜色,因此Spinner选择的项目颜色默认为黑色,因此它不可见.
我希望通过xml或更新样式将此颜色更改为白色,以便它可以在黑色中显示.
<Spinner
android:id="@+id/countrySpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:hint="@string/country" />
Run Code Online (Sandbox Code Playgroud)

有什么办法吗?提前致谢.
我正在为 android 构建一个简单的应用程序,它由微调器和编辑文本组成。问题是我在适配器Spinner 1 中有 2 个带有数组的
微调器
ArrayAdapter adapter1 = ArrayAdapter.createFromResource(this,R.array.kendaraan_arrays,android.R.layout.simple_spinner_item);
spKendaraan.setAdapter(adapter1);
Run Code Online (Sandbox Code Playgroud)
我想要的是微调器 2 中的数组取决于我在微调器 1 中选择的内容微调
器 2
@Override
public void onItemSelected (AdapterView < ? > adapterView, View view,int position, long id){
if (spKendaraan.getSelectedItem().equals("Mobil")) {
Toast.makeText(getApplicationContext(), "Mobil dipilih", Toast.LENGTH_SHORT).show();
ArrayAdapter adapter2 = ArrayAdapter.createFromResource(this, R.array.pelanggaran_mobil, android.R.layout.simple_spinner_item);
spPelanggaran.setAdapter(adapter2);
} else {
ArrayAdapter adapter2 = ArrayAdapter.createFromResource(this, R.array.pelanggaran_motor, android.R.layout.simple_spinner_item);
spPelanggaran.setAdapter(adapter2);
}
}
Run Code Online (Sandbox Code Playgroud)
我上面的代码不起作用,我是否犯了逻辑/方法错误?
tl;博士
if spinnerA == x{
spinnerB = m
}
else {
spinnerB = n
}
Run Code Online (Sandbox Code Playgroud)
由于我是 android …
我正在使用微调器,并使用所有选项填充下拉菜单。我遇到的问题是,当出现下拉菜单时,它会阻止当前选择的内容。
\n\n这是演示的图片和我的代码:
\n\n\n\n if(field.getType().equalsIgnoreCase("select"))\n {\n CSSelect select = (CSSelect) field;\n\n LinearLayout ll = new LinearLayout(this);\n final Spinner s = new Spinner(this);\n\n TextView t = new TextView(this);\n t.setText("\xe2\x96\xbc");\n t.setTextSize(12);\n t.setBackgroundResource(R.drawable.spinnerbg);\n t.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n s.performClick();\n }\n });\n\n LinearLayout.LayoutParams slp = new LinearLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT);\n s.setLayoutParams(slp);\n\n ll.addView(s);\n ll.addView(t);\n\n s.setBackgroundResource(R.drawable.spinnerbg);\n\n List<String> list = new ArrayList<String>();\n\n JSONArray choices = select.getChoices();\n\n for(int j = 0; j < choices.length(); j++)\n {\n JSONObject jObj = choices.getJSONObject(j);\n String st = jObj.getString("text");\n list.add(st);\n …Run Code Online (Sandbox Code Playgroud) 我试图在按下按钮时弹出一个警告对话框,并向用户显示一些要填写的字段,以及一个用于选择正确选项的下拉菜单。
这是我的当前代码,但我觉得我需要创建一个自定义适配器而不是使用基本适配器,但我不确定如何创建一个。提前感谢您的帮助。
public void addWork() {
weightList = new ArrayList<String>();
weightRes.moveToFirst();
for (int i = 0; i < weightRes.getCount(); i++) {
weightList.add(weightRes.getString(1));
}
Context context = ClassDescription.this;
final LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
final EditText titleBox = new EditText(context);
titleBox.setHint("Title");
layout.addView(titleBox);
final EditText pointsEarned = new EditText(context);
pointsEarned.setHint("Points Earned");
layout.addView(pointsEarned);
final EditText maxPoints = new EditText(context);
maxPoints.setHint("Total Possible Points");
layout.addView(maxPoints);
final Spinner sp = new Spinner(ClassDescription.this);
sp.setLayoutParams(new LinearLayout.LayoutParams(AbsListView.LayoutParams.WRAP_CONTENT, AbsListView.LayoutParams.WRAP_CONTENT));
sp.setAdapter(adp);
layout.addView(sp);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.work_dialog, weightList);
sp.setAdapter(adapter); …Run Code Online (Sandbox Code Playgroud) 我正在为我的微调器使用自定义设计,但文本在微调器的右侧图标上重叠。请查看所附图片。
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spinnerMode="dialog"
android:background="@drawable/spinner_bg"
android:id="@+id/mySpinner"
android:prompt="Testing"
android:layout_marginTop="8dp" />
Run Code Online (Sandbox Code Playgroud)
spinner_bg.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item>
<shape>
<gradient
android:startColor="#6e95bd"
android:endColor="#517295"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#000" />
<corners
android:radius="50dp" />
</shape>
</item>
<item>
<bitmap android:gravity="right|center_vertical" android:src="@mipmap/ic_spinner_down"/>
</item>
</layer-list>
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)
我正在开发一个应用程序,我已经填充了listview解析器json。现在我必须在这一listview行中添加本地微调器数组。如何在该listview行内添加本地旋转器数组。而且我还想获得选定的微调器值listview。以下是我的代码,请建议我。
//activity
public class MyModifyPgmLvAddUserActivity1 extends AppCompatActivity {
private DBManager dbManager;
private ListView listView, listView1;
Toolbar toolbar;
private String TAG = MyModifyPgmLvAddUserAdapter.class.getSimpleName();
private ProgressDialog pDialog;
// private SimpleCursorAdapter adapter;
MyModifyPgmLvAddUserAdapter1 adapter;
static String RANK = "AsanaId";
static String COUNTRY = "Asananame";
static String POPULATION = "repetation";
ArrayList<PojoList> SubjectList = new ArrayList<PojoList>();
final static String[] mSpinnerItems = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
private static String url …Run Code Online (Sandbox Code Playgroud) 这是我的代码:
transactionTypeSpinner.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(MainActivity.this, "Something changed", LENGTH_SHORT).show();
}
});
Run Code Online (Sandbox Code Playgroud)
但不幸的是OnItemClickListener方法不起作用并显示此消息:setOnItemClickListener cannot be used with a spinner.
我该如何解决这个问题?
谢谢!
我ArrayList.Indexof("Value")在我的一个应用程序中使用.ArrayList包含400多个值,我使用此List在spinner中显示.我想将微调器移动到特定位置,因为我需要该Indexof项目.我正在使用Spinner,setSelection但这里ArrayList.Indexof("Value")返回-1 ...为什么??? 请帮我..