New Activity Android

 Main Activity 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ddd"
android:padding="20dp"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Shamim Hossen!"
android:textSize="30sp"
android:gravity="center"
/>
<ImageView
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@drawable/tashbeeh"
android:scaleType="centerCrop"/>
<Button
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Click Here Our Button"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="horizontal">
<Button
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click"
/>
<Button
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click "
/>
<Button
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click"
/>

</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/TExtViewf"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" Shamim Hosen "
android:textSize="30dp"
android:gravity="center"
/>
<Button
android:id="@+id/ClickButton"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Click Here Our Button"/>

</LinearLayout>
</LinearLayout>
Manin Activity Java
package com.example.mypage;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {
TextView TxtViewf;
Button ClickButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

TxtViewf = findViewById(R.id.TExtViewf);
ClickButton = findViewById(R.id.ClickButton);

ClickButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TxtViewf.setText("Shamim Hose");
TxtViewf.setVisibility(View.GONE);
Toast.makeText(MainActivity.this,"shamim Hosen Is the best", Toast.LENGTH_LONG)
.show();
}
});










}
}

 

Post a Comment

Previous Post Next Post
Girl in a jacket