I have set up an ImageView in main.xml, if I want to access it from my View class and make it visible = false, how can I do this programatically?
Thank you
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
theView = new GameView(this);
theView.setBackgroundResource(R.layout.main);
setContentView(theView);
For example, in your layout xml file, there is a imageview1
<ImageView
android:id="@+id/imageview1"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
in your java src,
ImageView img=(ImageView)findViewById(R.id.imageview1);
img.setVisibility(View.GONE);
img.setVisibility(View.VISIBLE);
img.setVisibility(View.INVISIBLE);
you can google the difference between View.Gone and View.VISIBLE
First you should retrieve a link to this view object. Than set visibility property of this object to View.INVISIBLE
ImageView imageView = (ImageView)findViewById(R.id.image_view);
imageView.setVisibility(View.INVISIBLE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With