单击文本视图设置微调器或选择对话框

时间:2011-12-13 12:14:01

标签: android

我有一些文本视图,我已将其设为可点击,现在当我点击它时,它应该生成一个带有一些选项的微调框。

3 个答案:

答案 0 :(得分:0)

试试这个...... 粘贴以下代码点击textview

 s = (Spinner) findViewById(R.id.spinner);
           s.setvisibility(View.Visible)  ;
           ArrayAdapter adapter = ArrayAdapter.createFromResource(this,
                   R.array.planets, android.R.layout.simple_spinner_item);
           adapter.setDropDownViewResource(
                   android.R.layout.simple_spinner_dropdown_item);
           s.setAdapter(adapter);

           // Open the Spinner...
           s.performClick();

所有最好的

答案 1 :(得分:0)

尝试这种方法..

public void spinnerShow(){  
  AlertDialog dialog ;
    Charsequence str[]={"Test1","Test2"};


    AlertDialog.Builder builder=new AlertDialog.Builder(this);
    builder.setTitle("Your Title Here");
    builder.setItems(str, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int position) {
                    //here you can use like this... str[position]

                }

            });
            dialog = builder.create();
            dialog.show();

}

答案 2 :(得分:0)

试试这个

textview.setOnClickListener(new View.OnClickListener()  {
    public void onClick(View v)  {
        spinner_show();
        }
    });
Spinner size_spinner = (Spinner)findViewById(R.id.size_spinner);


private void spinner_show()  {
  ArrayAdapter sizeArrayAdapter = new ArrayAdapter(this, 
                                      android.R.layout.simple_spinner_item,sizeArray);

    size_spinner.setAdapter(sizeArrayAdapter);
    size_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) {

        }
        public void onNothingSelected(AdapterView<?> parent) {
        } 
    });

}