2011-12-13 58 views

回答

0

嘗試這個... 粘貼下面的代碼的onclick的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(); 

一切順利

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(); 

} 
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) { 
     } 
    }); 

}