dropbox link on the project folderAndroid Studio中微调导致应用程序崩溃甚至打开
每当我跑在Android模拟器工作室,它会自动崩溃的应用程序之前。任何人都可以帮我解决我在这里做的错误吗?这里只是特定的微调代码。但链接有应用程序。
List <String> empSale = new ArrayList <String>();
empSale.add("Sale Items:");
empSale.add("Apple iPhone 8");
empSale.add("Samsung Galaxy 9");
empSale.add("Asus Zenfone 10");
empSale.add("Nokia 3310");
spnSale = (Spinner) findViewById(R.id.spnSale);
spnSale.setOnItemSelectedListener((AdapterView.OnItemSelectedListener) this);
//Spinner data
aA = new ArrayAdapter <String> (this, android.R.layout.simple_spinner_dropdown_item, empSale);
aA.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnSale.setAdapter(aA);
spnSale.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView <<?> parent, View view, int position, long id) {
String items = parent.getItemAtPosition(position).toString();
Toast.makeText(parent.getContext(), "Selected " + items, Toast.LENGTH_SHORT).show();
if (items.equals("Sale Items:")) {
//price = 0;
txtPrice.setText("Price: Php 0.00");
}
if (items.equals("Apple iPhone 8")) {
//price = 60000;
txtPrice.setText("Price: Php 60000.00");
}
if (items.equals("Samsung Galaxy 9")) {
//price = 55000;
txtPrice.setText("Price: Php 55000.00");
}
if (items.equals("Asus Zenfone 10")) {
//price = 50000;
txtPrice.setText("Price: Php 50000.00");
}
if (items.equals("Nokia 3310")) {
//price = 1000000;
txtPrice.setText("Price: Php 1000000.00");
}
}
});
有什么错误。 logcat中有崩溃日志吗? – litelite
尝试使用'aA = new ArrayAdapter < String >(this,android.R.layout.simple_list_item_1,empSale);' –
@litelite它不显示任何崩溃错误 –