我可以修改我的第一个微调器,但不知道如何在java中执行第二个微调器。这是我正在尝试的,当我启动活动时,我得到没有明显错误但我的apk fc是。当你在相同的布局和相同的重要性上覆盖两件事时,有人可以帮助我解决java代码的问题吗?提前致谢。 (现在回到寻找一个例子)
package com.wbhome.mytrial;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class m5isoActivity extends m5Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scores);
Spinner localSpinner = (Spinner)findViewById(R.id.iso_pbar_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.iso_pbar_list, R.layout.my_normal_spinner_style);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
localSpinner.setAdapter(adapter);
}
{
Spinner localSpinner = (Spinner)findViewById(R.id.iso_sp_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.iso_sp_list, R.layout.my_normal_spinner_style);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
localSpinner.setAdapter(adapter);}
}
答案 0 :(得分:0)
我不认为你的编译器工作,它应该指向红色警告(错误),因为你正在为ArrayAdapter创建两个具有相同名称和相同内容的Spinners。至少改变变量的名称。
答案 1 :(得分:0)
不要使用初始化程序块!排列您的{
和}
,以便了解您的方法,代码块和类的开始和结束位置。
public class m5isoActivity extends m5Activity {//start of class
@Override
public void onCreate(Bundle savedInstanceState) { //start of method
super.onCreate(savedInstanceState);
setContentView(R.layout.scores);
Spinner localSpinner = (Spinner)findViewById(R.id.iso_pbar_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.iso_pbar_list, R.layout.my_normal_spinner_style);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
localSpinner.setAdapter(adapter);
} //onCreate method ends here
{ //following code is a initalizer block,
//you should move this into a method
Spinner localSpinner = (Spinner)findViewById(R.id.iso_sp_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.iso_sp_list, R.layout.my_normal_spinner_style);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
localSpinner.setAdapter(adapter);}//end of initializer block
}//end of class
答案 2 :(得分:0)
我只是做了很多他的希望,这有帮助
Spinner m1ssspinner = (Spinner)findViewById(R.id.m1_ss_spinner);
ArrayAdapter<CharSequence> m1ssadapter = ArrayAdapter.createFromResource(this, R.array.m1_ss_list, R.layout.my_normal_spinner_style);
m1ssadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
m1ssspinner.setAdapter(m1ssadapter);
Spinner m1sqs1spinner = (Spinner)findViewById(R.id.m1_sqs1_spinner);
ArrayAdapter<CharSequence> m1sqs1adapter = ArrayAdapter.createFromResource(this, R.array.m1_sqs1_list, R.layout.my_normal_spinner_style);
m1sqs1adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
m1sqs1spinner.setAdapter(m1sqs1adapter);