2017-01-12 2 views
1

안녕하세요. 현재 회 전자가 클릭되었을 때 표시되지 않는 문제가 발생했습니다. 내가 무엇을 잘못해서 잘못했는지 알지 못한다. 죄송 정지 화상 안드로이드와 자바 PLS 도움말 새로운 ....클릭하면 회 전자가 표시되지 않음

public class SpinnerInfo extends MainProduct { 
Spinner spinners; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    spinners = (Spinner) findViewById(R.id.spinner); 
    final ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.type_arrays, R.layout.support_simple_spinner_dropdown_item); 
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_item); 
    spinners.setAdapter(adapter); 
    spinners.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 
     @Override 
     public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { 
      String [] dataArray = getResources().getStringArray(R.array.type_arrays); 
      String type = dataArray[position];} 

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

내 XML

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@android:color/darker_gray" 
android:orientation="vertical" 
android:elevation="1dp" 
android:weightSum="1"> 

<TextView 
    android:text="Product List" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/textView" 
    android:textSize="24sp" 
    android:textStyle="normal|italic" 
    android:textAlignment="center" 
    android:fontFamily="casual" 
    android:textColor="@android:color/background_dark" 
    android:layout_marginTop="10dp"/> 

<TextView 
    android:text="Select Type:" 
    android:layout_width="100dp" 
    android:layout_height="wrap_content" 
    android:id="@+id/textView2" 
    android:textAlignment="textStart" 
    android:textStyle="normal|bold" /> 

<Spinner 
    android:layout_width="126dp" 
    android:layout_height="wrap_content" 
    android:id="@+id/spinner" 
    /> 

<ListView 
    android:id="@+id/listview_product" 
    android:layout_width="match_parent" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="10dp" 
    android:divider="@android:color/darker_gray" 
    android:dividerHeight="8dp" 
    android:background="@android:color/white" 
    android:layout_height="match_parent"> 

</ListView> 

답변

1
final ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.type_arrays, R.layout.support_simple_spinner_dropdown_item); 

당신이 그런데

final ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.layout.support_simple_spinner_dropdown_item, R.array.type_arrays); 
+0

안녕하세요. – Jason

0

에 이 parent.get을 할 수있을 때 문자열 리소스에 액세스합니다. ItemAtPosition (위치)

관련 문제