Issue
My main Thread extends from Activity, it starts two asynchronous tasks that gather data from different UDP sources. One of this tasks should append the data to this graph drawing library. I am making updates on the UI from the onPostExecute section of AsynTask:
@Override
protected void onPostExecute(Integer result) {
super.onPostExecute(result);
edt2.setText(Integer.toString(result));
// Graph Update
if (graphActive) {
exampleSeries1.appendData(ATList.get(ATList.size()-1), true);
} else {
//do nothing
}
}
The data is passed to the graph and if I click with my finger on the display it is displayed correctly, but I want the software to update the graph automatically. The edt2 textfield is updated automatically.
I tried the following:
layout.postInvalidate(); //and invalidate
I have no idea how to make Android to update the GraphView.
This is the respective part of the XML:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/graph1"
android:layout_width="match_parent"
android:layout_height="305dp" >
</LinearLayout>
Thank you very much for your help!
Solution
AsyncTask is not a Ui Thread use runOnUiThread(..) instead Asynctask.
1 rl-: parent view. 2 myView -: Child View
//Use This Method //
runOnUiThread(new Runnable() {
//@Override
public void run() {
// TODO Auto-generated method stub
rl.addView(new myView(getApplicationContext()));
}
});
Answered By - Rishabh Agrawal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.