public class dz extends Activity implements OnClickListener {
/** Called when the activity is first created. */
EditText priceinput;
EditText discount;
Button btncalc;
TextView textView;
//Button btnShowDialog_Layout;
Button b_calc;
Button b_bztz;
Button b_gotg;
Spinner s1 ;
View myView;
int isloaging=0;
ProgressDialog progressDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
this.setTitle("Lee's tool");
setContentView(R.layout.login);
// setContentView(R.layout.main);
LayoutInflater mInflater = LayoutInflater.from(this);
myView = mInflater.inflate(R.layout.main, null);
Thread thread = new Thread(){
public void run(){
try {
Thread.sleep(2000);
Message m = new Message();
m.what=1;
dz.this.mHandler.sendMessage(m);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
};
thread.start();
this.priceinput=(EditText)myView.findViewById(R.id.edtInput);
this.discount=(EditText)myView.findViewById(R.id.edtInput2);
this.btncalc=(Button)myView.findViewById(R.id.btnShow);
this.b_bztz=(Button)myView.findViewById(R.id.btnbztz);
this.b_gotg=(Button)myView.findViewById(R.id.btnClear);
this.b_gotg.setOnClickListener(this);
this.btncalc.setOnClickListener(this);
this.b_bztz.setOnClickListener(this);
this.textView=(TextView)myView.findViewById(R.id.TextView03);
this.s1 = (Spinner) findViewById(R.id.citys);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.fujian, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
this.s1.setAdapter(adapter);注1
}
private Handler mHandler = new Handler(){
public void handleMessage(Message msg) {
if (msg.what==2)
{
String st = msg.getData().getString("St");
dz.this.textView.setText(st);
progressDialog.dismiss();
}
if (msg.what==1)
{ setContentView(myView);
}
}
};
以上的小弟写的一个测试代码,想达到的想法是进入一个页面 有一个logo的页面,延时几秒钟后进入 main页面,但是main页面有一个Spinner,初始化的时候,发现在多线程下 每次跑到注1的位置就崩掉了,说没有找到adapter,各位大哥大姐有啥解决办法没啊
/** Called when the activity is first created. */
EditText priceinput;
EditText discount;
Button btncalc;
TextView textView;
//Button btnShowDialog_Layout;
Button b_calc;
Button b_bztz;
Button b_gotg;
Spinner s1 ;
View myView;
int isloaging=0;
ProgressDialog progressDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
this.setTitle("Lee's tool");
setContentView(R.layout.login);
// setContentView(R.layout.main);
LayoutInflater mInflater = LayoutInflater.from(this);
myView = mInflater.inflate(R.layout.main, null);
Thread thread = new Thread(){
public void run(){
try {
Thread.sleep(2000);
Message m = new Message();
m.what=1;
dz.this.mHandler.sendMessage(m);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
};
thread.start();
this.priceinput=(EditText)myView.findViewById(R.id.edtInput);
this.discount=(EditText)myView.findViewById(R.id.edtInput2);
this.btncalc=(Button)myView.findViewById(R.id.btnShow);
this.b_bztz=(Button)myView.findViewById(R.id.btnbztz);
this.b_gotg=(Button)myView.findViewById(R.id.btnClear);
this.b_gotg.setOnClickListener(this);
this.btncalc.setOnClickListener(this);
this.b_bztz.setOnClickListener(this);
this.textView=(TextView)myView.findViewById(R.id.TextView03);
this.s1 = (Spinner) findViewById(R.id.citys);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.fujian, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
this.s1.setAdapter(adapter);注1
}
private Handler mHandler = new Handler(){
public void handleMessage(Message msg) {
if (msg.what==2)
{
String st = msg.getData().getString("St");
dz.this.textView.setText(st);
progressDialog.dismiss();
}
if (msg.what==1)
{ setContentView(myView);
}
}
};
以上的小弟写的一个测试代码,想达到的想法是进入一个页面 有一个logo的页面,延时几秒钟后进入 main页面,但是main页面有一个Spinner,初始化的时候,发现在多线程下 每次跑到注1的位置就崩掉了,说没有找到adapter,各位大哥大姐有啥解决办法没啊
解决方案 »
- The method readLine() from the type DataInputStream is deprecated
- JDBC的疑惑?
- 谁能介绍一个好的界面开发工具
- 请高手推荐几本学习GUI入门级的书和一些资料!
- Iterator的数据结构是什么呢?
- 又是一个奇怪路径问题
- 请问:默认的倒入包是什么?
- obliang(无影):关于在浏览器中不使用JRE显示非标准JVM类库(包括SWING,com.sun等)的方法。
- 关于JTable渲染器Renderer的问题,求高手解答!!!!
- split()方法使用的疑问,关于分隔符。
- 今天外包的 sql 面试题
- 出圈的算法,大家看下有时间复杂度更低的方法没?
你再调查一下。