getting "unfortunately has stopped" error when using resources
I think I don't need to tell what I try to but I want to tell. There is 2
<string-array> first is for android:entries second for values of these
entries. When user select the item I want to get value of that item.
Also I want to ask, When application is opened, dialog run. I want to make
it run just when after user select a item.
public class Select extends Activity implements OnItemSelectedListener{
Resources rsc = getResources();
@SuppressLint("Recycle")
final TypedArray itemValues = rsc.obtainTypedArray(R.array.selectValues);
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.select);
Spinner form = (Spinner) findViewById(R.id.sSelect);
form.setOnItemSelectedListener(this);
}
@Override
public void onItemSelected(AdapterView<?> item, View arg1, int sort,
long arg3) {
// TODO Auto-generated method stub
int selectedItem = itemValues.getInt(sort, 1);
Dialog d = new Dialog(this);
TextView t = new TextView(this);
t.setText(selectedItem);
d.setContentView(t);
d.setTitle("Sonuc!");
d.show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
Problem appear when I use Resources. Also logcat is here. What's the
problem and solution of this problem?
No comments:
Post a Comment