ui-thread

UI blocks when refreshing a listview (how to solve?)

非 Y 不嫁゛ 提交于 2019-12-11 08:34:47
问题 I have a button. On click, I am refreshing a list. What I am experiencing : The state_pressed color stays for a big while (meaning the UI thread blocked) (Note: the button background is defined such as on state_pressed="true" the color changes) Question : How can I click the button to refresh the list, without blocking the UI? My Code : mButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { refreshListView(data); } }); public void refreshListView(ArrayList data)

WP7 - accessing UI thread?

风流意气都作罢 提交于 2019-12-11 07:32:40
问题 How do I access the UI thread of a WP7 application? I am using the following code, if it helps. private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { AcquireNews(l => { listBox1.Items.Add(l[0]); }); // Here is where I get an exception saying "Invalid cross-thread access." } void AcquireNews(Action<List<object>> callback) { var r = HttpWebRequest.Create("http://www.google.com") as HttpWebRequest; r.BeginGetResponse(result => { var response = r.EndGetResponse(result); List<object>

RecyclerView blocking ui thread during updates

旧时模样 提交于 2019-12-11 01:49:09
问题 There are more than 200 items in my list. RecyclerView is updated regularly (Every 10 seconds) . RecyclerView blocking ui thread for few seconds during updates. I'm using notifyDataSetChanged method for refresh recyclerview. Is there another way to prevent freezing ? By the way I don't want use pagination. This method run every 10 seconds : public void refreshAssetList(List<Asset> newAssetList){ recyclerViewAdapter.setAssetList(newAssetList); recyclerViewAdapter.notifyDataSetChanged(); }

Handling UI from other thread

牧云@^-^@ 提交于 2019-12-10 18:46:46
问题 I have a class which extends the Runnable . This class performs some heavy operation (basically downloads the image from network) in different thread. I want to update the UI (display the downloaded image to an ImageView ) from this class. I have tried using handler but did not succeed. Here is my code: class DataReceiver implements Runnable { public Bitmap bmp; Public Handler uiHandle; @Override public void run() { while(true) { //do image download process here } } } In main activity

Setting TextView visible from another thread or BeginInvoke in Android

与世无争的帅哥 提交于 2019-12-10 17:11:33
问题 I'm developing an Android 2.2 application. I have an event listener on an activity, and I want to set visible a TextView when I receive an event. But there is an error: I only can set it visible from UI thread. In C# and Windows Mobile there is a BeginInvoke. Is there something similar in Android? Thanks. 回答1: You can use Activity#runOnUiThread or an AsyncTask as the two easiest ways to duplicate the BeginInvoke functionality; with runOnUiThread being the one most similar. For more

ArrayAdapter need to be clear even i am creating a new one

北城以北 提交于 2019-12-08 12:48:15
问题 Hello I'm having problems understanding how the ArrayAdapter works. My code is working but I dont know how.(http://amy-mac.com/images/2013/code_meme.jpg) I have my activity, inside it i have 2 private classes.: public class MainActivity extends Activity { ... private void SomePrivateMethod(){ autoCompleteTextView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, new ArrayList<String>(Arrays.asList("")))); autoCompleteTextView.addTextChangedListener(new

handling too many requests of animation on the main ui thread from other threads - android

僤鯓⒐⒋嵵緔 提交于 2019-12-08 09:01:16
问题 I am working on creating activity that has too many animations, and when starting this activity the logcat shows me this message again and again during the life time of this activity: I/Choreographer﹕ Skipped 36 frames! The application may be doing too much work on its main thread. so I did many stuff in another threads, but still there is heavy access on the main UI thread. as well as, the animation is becoming really slow on some high resolution devices what can be possible solution for

How to flash a button on UI thread?

淺唱寂寞╮ 提交于 2019-12-08 06:25:31
I have a button on my UI that I would like to flash (turn on and then off again) every 800ms, once the button has been pressed. I do that with the following code: - (void)flickEmergencyButton { // Check whether an emergency is in progress... if (model.emergencyInProgress) { // ...and if so, flick the state self.emergencyButton.selected = !self.emergencyButton.selected; // Make this method be called again in 800ms [self performSelector:@selector(flickEmergencyButton) withObject:nil afterDelay:0.8]; } else { // ...otherwise, turn the button off self.emergencyButton.selected = NO; } } ...which

Using HandlerThread and Handler on a separate thread freezes UI thread

旧街凉风 提交于 2019-12-08 05:59:47
问题 In my project, I want to implement a timer in another thread that counts down the time spent executing a certain method in my application, and do something if it is taking too much time. When executing the MyManager.startCommand() method, the application is freezing and I don't know why since I think I am not doing anything on the UI thread. Is there anything wrong with my code? I had originally asked this question and was not experiencing an app freeze, so I don't think it's because I'm

How to flash a button on UI thread?

自作多情 提交于 2019-12-08 04:32:07
问题 I have a button on my UI that I would like to flash (turn on and then off again) every 800ms, once the button has been pressed. I do that with the following code: - (void)flickEmergencyButton { // Check whether an emergency is in progress... if (model.emergencyInProgress) { // ...and if so, flick the state self.emergencyButton.selected = !self.emergencyButton.selected; // Make this method be called again in 800ms [self performSelector:@selector(flickEmergencyButton) withObject:nil afterDelay