开发者

Update Spinner value when activity is open?

开发者 https://www.devze.com 2023-03-01 04:05 出处:网络
Hii i 开发者_Python百科have a thread that runs and retrieve values for the spinnner from the server till then the spinnner is empty how can i update the values of the spinner when i get the values ..a

Hii i 开发者_Python百科have a thread that runs and retrieve values for the spinnner from the server till then the spinnner is empty how can i update the values of the spinner when i get the values ..and my activity is open at that time.

ArrayList valforspinner=new ArrayList();

new Thread(new Runnable() {
            public void run() {         
        valforspinner= GetList.List(myPrefs.getString("IP", ""));
        adapter.notifyDataSetChanged();
            }}).start();


    spinner = (Spinner) findViewById(R.id.Spinner01);
     adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, Printers);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);


Call notifyDataSetChanged() on the Adapter used to fill the Spinner.

0

精彩评论

暂无评论...
验证码 换一张
取 消