更新Android的一个微调 [英] Update a spinner in Android

查看:141
本文介绍了更新Android的一个微调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序有1微调选项。在我6显示值(从值文件数组)。现在,当我点击了5个项目的微调值的所选项目将显示在屏幕上的活动微调。

当我在微调中选择第6项,我要开始新的活动。可能吗?我一定要由位置值做到这一点?

另外,在新的活动(后选择第6项),我在其中用户可以输入一个字符串应该替换微调的旧值5的EditText值。是否可以动态更新的微调?

我的飞旋code:

 微调S2 =(微调)findViewById(R.id.spinner1);
ArrayAdapter<&CharSequence的GT;适配器1 = ArrayAdapter.createFromResource(
  对此,R.array.group_array,android.R.layout.simple_spinner_item);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s2.setAdapter(适配器1);


解决方案

这是可能的。

的编码

  ArrayAdapter yearadp =新ArrayAdapter(这一点,android.R.layout.simple_spinner_item,yearlist);
            yearadp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);         year_spinner.setAdapter(yearadp);
    索引= 0;     year_spinner.setOnItemSelectedListener(新AdapterView.OnItemSelectedListener(){
            公共无效onItemSelected(适配器视图<>母公司,观景,INT POS,长I​​D){
          spintext = parent.getItemAtPosition(POS)的ToString();                如果(spintext ==6)
                {
 意图=新意图(ListMonthActivity.this,NewChart.class);
 startActivity(意向);
 }
  }
    }

雅,我们可以用设置做

  mon_spinner.setSelection(iSelectedMonth);
意图=新意图(ListMonthActivity.this,NewChart.class);

您可能会或不提,而动作有一定的动作完成后,你可以传递到另一个活动。

In my application I have 1 spinner option. In that I am displaying 6 values (which is array from values file). Now in that when I click its 5 items of the spinner value the selected item will show in the spinner in the activity screen.

When I select 6th item in spinner I have to start a new activity. Is it possible? Do I have to do this by position value?

Also in the new activity (after selecting 6th item) I have 5 edittext values in which user can enter a string which should replace the old value in the spinner. Is it possible to dynamically update the spinner?

My spinner code:

Spinner s2=(Spinner)findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource(
  this, R.array.group_array, android.R.layout.simple_spinner_item);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s2.setAdapter(adapter1);     

解决方案

It's possible

Codings:

ArrayAdapter yearadp =  new ArrayAdapter(this,android.R.layout.simple_spinner_item,  yearlist);
            yearadp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

         year_spinner.setAdapter(yearadp);
    index=0;

     year_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
          spintext=parent.getItemAtPosition(pos).toString();

                if(spintext=="6")
                {
 intent        =    new Intent(ListMonthActivity.this,NewChart.class);
 startActivity(intent);
 }
  }
    }

Ya we can do with setting with

mon_spinner.setSelection(iSelectedMonth);
intent        =    new Intent(ListMonthActivity.this,NewChart.class);

You may or not mention while the action are certain action finished, and you can passed into another activity .

这篇关于更新Android的一个微调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆