<?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="#0D174C"
android:padding="20dp"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Shamim Hossen!"
android:textColor="@color/white"
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"/>
<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"
style="@style/CardView.Light"
android:layout_height="wrap_content"
android:text=" Digital Tashbi "
android:background="#DCE8EA"
android:textSize="30dp"
android:gravity="center"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="horizontal">
<Button
android:id="@+id/Add"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Add"
/>
<Button
android:id="@+id/zero"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="zero"
/>
<Button
android:id="@+id/sub"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sub"
/>
</LinearLayout>
<Button
android:id="@+id/ClickButton"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Activity Gone and Tost"/>
<Button
android:id="@+id/show"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Show"/>
<Button
android:id="@+id/Video1"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Play Video 1"/>
<Button
android:id="@+id/Video2"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Play Video 2"/>
</LinearLayout>
</LinearLayout>
package com.example.mypage;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
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,Video1,Video2,show,Add,zero,sub;
int count=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TxtViewf = findViewById(R.id.TExtViewf);
ClickButton = findViewById(R.id.ClickButton);
Video1= findViewById(R.id.Video1);
Video2= findViewById(R.id.Video2);
show=findViewById(R.id.show);
Add= findViewById(R.id.Add);
sub= findViewById(R.id.sub);
zero=findViewById(R.id.zero);
Add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
count++;
TxtViewf.setText(""+count);
}
});
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
count--;
TxtViewf.setText(""+count);
}
});
zero.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
count=0;
TxtViewf.setText(""+count);
}
});
show.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TxtViewf.setText("Shamim Hose");
TxtViewf.setVisibility(View.VISIBLE);
Toast.makeText(MainActivity.this,"shamim Hosen Show", Toast.LENGTH_LONG)
.show();
}
});
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();
}
});
Video1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
VideoPlayer.video_url="https://www.youtube.com/embed/vBm_LhIlNhY";
Intent myIntent =new Intent(MainActivity.this,VideoPlayer.class);
startActivity(myIntent);
}
});
Video2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
VideoPlayer.video_url="https://www.youtube.com/embed/uQ0LGwPBC2c";
Intent myIntent =new Intent(MainActivity.this,VideoPlayer.class);
startActivity(myIntent);
}
});
}
}
<?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"
tools:context=".VideoPlayer"
android:orientation="vertical">
<WebView
android:id="@+id/video_eb"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
package com.example.mypage;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
public class VideoPlayer extends AppCompatActivity {
public static String video_url="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_player);
WebView video_eb;
video_eb =findViewById(R.id.video_eb);
video_eb.getSettings().setJavaScriptEnabled(true);
video_eb.loadUrl(video_url);
}
}
Tags:
App-Development