Saturday, 15 February 2014

java - Update Android UI doesnt work -



java - Update Android UI doesnt work -

im searching 2 hours little error makes code doesnt work:

the activity:

updatethread t; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setrequestedorientation(activityinfo.screen_orientation_landscape); requestwindowfeature(window.feature_no_title); this.getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.activity_fullscreen); } @override protected void onresume() { t = new updatethread(this, this); t.start(); super.onresume(); }

and thread:

public updatethread(fullscreenactivity a, context c) { this.c = c; this.a = a; } @override public void run() { if(enabled) return; enabled = true; while(true) { a.runonuithread(new runnable() { @override public void run() { relativelayout view = (relativelayout) a.findviewbyid(r.id.view); view.removeallviews(); seek { textview t = new textview(c); t.settext("asd"); t.setvisibility(view.visible); t.setx(22); t.sety(123); t.setscalex(0.9f); t.setscaley(0.9f); t.setbackgroundcolor(color.yellow); view.addview(t); } catch(exception e) {e.printstacktrace();} log.d("finished drawing!"," drawed!"); } }); }

layout xml file:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/view" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="${packagename}.${activityclass}" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" android:id="@+id/asd"/> </relativelayout>

this code should add together textview fullscreenactivity, nil happens.

im using android level 12, software date, phone sgs3. give thanks you help, im looking forwards solution :)

java android multithreading user-interface

No comments:

Post a Comment