Android “Only the original thread that created a view hierarchy can touch its views.”

后端 未结 28 3178
鱼传尺愫
鱼传尺愫 2020-11-21 04:44

I\'ve built a simple music player in Android. The view for each song contains a SeekBar, implemented like this:

public class Song extends Activity implement         


        
28条回答
  •  温柔的废话
    2020-11-21 05:13

    You can use Handler to Delete View without disturbing the main UI Thread. Here is example code

    new Handler(Looper.getMainLooper()).post(new Runnable() {
                                                            @Override
                                                            public void run() {
                                                               //do stuff like remove view etc
                                                                adapter.remove(selecteditem);
                                                            }
                                                        });
    

提交回复
热议问题