Reputation: 379
I have main activity class and main layout. I have other class named time. I want to change set the icon on the main layout from other class. How can I do that ?
public class Time extends TimerTask
public class Main extends Activity
Time class is running on each 3 seconds. In run method, I have tried
ImageView image;
@Override
public void run() {
image = (ImageView) findViewById(R.id.imageView1);
image.setImageResource(R.drawable.android3d);
}
But, gives error. "findViewById" is not implemented in this class.
EDIT :
<ImageView
android:id="@+id/imageView1"
android:contentDescription="@string/isViolate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="0.04"
android:src="@drawable/set2" />
Upvotes: 0
Views: 411
Reputation: 2100
Try using
image = (ImageView) getView().findViewById(R.id.imageView1);
Upvotes: 1