Hy,我需要在旋转器上进行onclick.这是我的微调器:
Spinner spinner = (Spinner) findViewById(R.id.spnTarghe);
final String targhe[]=risposta.split("/");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this,
android.R.layout.simple_spinner_item,
targhe
);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)
如何使用onclicklistener来执行这个简单的构造:
sTarga=targhe[position];
Run Code Online (Sandbox Code Playgroud) 我目前正在使用android.support.v7包中包含的Action Bar来为我的应用添加Action Bar功能.我在添加导航微调器时遇到了问题.当应用程序在Honecomb之前的设备上运行时,微调器中的文本显得太暗而无法轻松读取,并且单选按钮与文本一起显示.我在我的values/styles.xml中定义的Honecomb之前的设备使用Theme.AppCompat主题,这是一个黑暗的主题,但不知何故主题未正确应用于Action Bar微调器.这是微调器初始化的代码.
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setDisplayShowTitleEnabled(false);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
actionBar.getThemedContext(),
android.R.layout.simple_spinner_dropdown_item,
android.R.id.text1, stringArrayGoesHere());
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
actionBar.setListNavigationCallbacks(adapter, null);
Run Code Online (Sandbox Code Playgroud)
我听说过Action Bar Sherlock等替代库,但我现在对它们的使用不感兴趣.
谢谢
android android-spinner android-actionbar android-support-library android-styles
是否可以使用微调器项设置标记.我想将我的bean对象设置为标记,每个微调器项都可以吗?
我正在开发一个 Android 应用程序,其中登录活动有 editText、RadioButton、Spinner 和一个按钮。因此,当按下按钮时,我必须通过检查是否填写了所有字段来验证我的表单,否则会向用户。任何人都可以帮我解决java代码吗?提前致谢。

public void OnClickListener(View v)
{
name=(EditText)findViewById(R.id.editText1);
years1=(RadioButton)findViewById(R.id.radioButton3);
years2=(RadioButton)findViewById(R.id.radioButton4);
years3=(RadioButton)findViewById(R.id.radioButton5);
manager=(RadioButton)findViewById(R.id.radioButton1);
teamleader=(RadioButton)findViewById(R.id.radioButton2);
rg1=(RadioGroup)findViewById(R.id.Designation);
rg2=(RadioGroup)findViewById(R.id.Years);
Button proceed = (Button) findViewById(R.id.button1);
proceed.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
if (validationSuccess())
{
}
else if(manager.isChecked())
{
Intent managerIntent = new Intent(getApplicationContext(), ManagerQuestionnaire1.class); // <----- START "SEARCH" ACTIVITY
startActivityForResult(managerIntent, 0);
}
else if(teamleader.isChecked())
{
Intent teamleaderIntent = new Intent(getApplicationContext(), TeamleaderQuestionnaire1.class); // <----- START "TYPE ENTRIES OUT" ACTIVITY
startActivityForResult(teamleaderIntent, 0);
}
else {
AlertDialog();
}
}
});
}
private …Run Code Online (Sandbox Code Playgroud) validation android buttonclick android-spinner onclicklistener
为什么片段不支持微调器?我有以下片段类并向其中添加了微调器。
public class SettingFragment extends Fragment {
Spinner spinner1;
public List<String> genderitems, titleitems;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View rootview = inflater.inflate(R.layout.settinglayout, container,
false);
spinner1 = (Spinner) rootview.findViewById(R.id.usertitle);
titleitems = new ArrayList<String>();
setTitleSpinnerContent(rootview);
titleitems.add("Beginner");
titleitems.add("Novice");
return rootview;
}
private void setTitleSpinnerContent(View view) {
ArrayAdapter<String> adp = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_dropdown_item_1line, titleitems);
adp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(adp);
}}
Run Code Online (Sandbox Code Playgroud)
如何在选择时获取微调器更改值并将其添加到微调器上的文本视图。我在这里缺少什么?提前致谢。
我什至尝试添加 onitemselectedlistener() 但结果也是零。
我正在尝试一个简单的应用程序,在该应用程序中,我使用从网络调用中获得的值(json 值)填充微调器。但是当从微调器中选择一个项目时,我不知道如何获取关联的 json 值。任何人都可以向我提供有关如何执行此操作的文章/参考资料吗?
这是我的 json 响应
{
item: {
name: "xyz",
brands: [
{
id: 123,
name: "abc"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我解析json的方式。
public class user_activity extends ActionBarActivity {
RequestQueue queue;
ArrayList<String> brand_list = new ArrayList<String>();
Spinner spinner;
String brand_id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_activity);
this.spinner= (Spinner) findViewById(R.id.spinner);
loadUser();
}
public void loadUser() {
final ProgressDialog pDialog = new ProgressDialog(this);
pDialog.setMessage("Please Wait..");
pDialog.show();
queue = Volley.newRequestQueue(this);
String url = "http://myApiUrl";
JsonObjectRequest postRequest = new JsonObjectRequest(Request.Method.GET, url, …Run Code Online (Sandbox Code Playgroud) 有没有设置默认微调器位置的方法,我只想在微调器标题下方显示我的微调器窗口,但通常当我们单击微调器时,标题上方会弹出窗口,那么有什么方法可以在标题下方显示弹出窗口.
我有一个场景,我想在用户键入内容时过滤数据。我目前正在使用 Spinner,但我想要的是用户应该能够在 Spinner 本身上写入数据,并且数据在运行时被过滤。我找不到与我想要的类似的东西。
类似于下图的东西(它是 ASP.net 中使用的 RadcomboBox 示例)。
在我的应用程序中,我想使用Spinner这个库:在此处输入链接描述
我使用以下代码从服务器获取数组列表:
InterfaceApi api = ApiClient.getClient().create(InterfaceApi.class);
Call<StringListDataResponse> call = api.getGetAggregationGenres();
call.enqueue(new Callback<StringListDataResponse>() {
@Override
public void onResponse(Call<StringListDataResponse> call, Response<StringListDataResponse> response) {
if (response.body().getData() != null) {
spinner.setItems(response.body().getData());
}
}
@Override
public void onFailure(Call<StringListDataResponse> call, Throwable t) {
}
});
Run Code Online (Sandbox Code Playgroud)
Spinner 所选商品代码:
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
@Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
Snackbar.make(view, "Clicked " + item, Snackbar.LENGTH_LONG).show();
}
});
Run Code Online (Sandbox Code Playgroud)
但我想为这个微调器设置默认值。
首先显示我的默认值,当所选项目从列表中显示此项目。
我怎么能呢?
我为spinner创建了一个自定义适配器类,它可以获取对象类型值.但奇怪的是它在代码中显示出一些错误.
SpinAdapter类
public class SpinAdapter extends ArrayAdapter<Country>
{
private Context context;
private Country[] values;
public SpinAdapter(Context context, int textViewResourceId, Country[] values)
{
super(context, textViewResourceId, values);
this.context = context;
this.values = values;
}
public int getCount(){
return values.length;
}
public Country getItem(int position){
return values[position];
}
public long getItemId(int position){
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView label = new TextView(context);
label.setTextColor(Color.BLACK);
label.setText(values[position].getName());
return label;
}
@Override
public View getDropDownView(int position, View convertView,
ViewGroup …Run Code Online (Sandbox Code Playgroud)