0% found this document useful (0 votes)
21 views

FrameLayout Image Program

The document contains XML code for a FrameLayout containing two ImageViews with different widths and heights. It also contains Java code for a class that sets onclick listeners on the ImageViews to toggle their visibility when clicked. When one ImageView is clicked, it is hidden and the other is shown, and vice versa.

Uploaded by

Lipi's Khazana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

FrameLayout Image Program

The document contains XML code for a FrameLayout containing two ImageViews with different widths and heights. It also contains Java code for a class that sets onclick listeners on the ImageViews to toggle their visibility when clicked. When one ImageView is clicked, it is hidden and the other is shown, and vice versa.

Uploaded by

Lipi's Khazana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

<FrameLayout

xmlns:android="http://schemas.android
.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent" >

<ImageView
android:id="@+id/imageView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/ic_launcher"
/>

<ImageView
android:id="@+id/imageView2"

android:layout_width="wrap_content"
android:layout_height="456dp"
android:src="@drawable/logo"
/>

</FrameLayout>

Java Code
package com.example.framelayoutnew;

import android.app.Activity;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.ImageView;

public class MainActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

final ImageView i1=(ImageView)findViewById(R.id.imageView1);

final ImageView i2=(ImageView)findViewById(R.id.imageView2);

i1.setOnClickListener(new OnClickListener(){

public void onClick(View view){

i2.setVisibility(View.VISIBLE);

view.setVisibility(View.GONE);

});

i2.setOnClickListener(new OnClickListener(){

public void onClick(View view){

i1.setVisibility(View.VISIBLE);

view.setVisibility(View.GONE);

});
}

You might also like