Android Studio
Explaination of the project :
- That project is like a mini project for to improve in your developing skills in android studio.
- In this i would be paste the differnt types of file code
- that all the file give a good understanble
- First file name is Active_main.xml
- And that file Backend file name MainActivity.java file
- then second file name is Activity_main2.xml
- the second file backend is MainActivity2.xml
- And last importen file is Mainfeast.xml file
- if you want pref explain about the file please commend below
File 1
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="#FFFFFF"
tools:context=".MainActivity">
<ImageView
android:id="@+id/image"
android:layout_width="84dp"
android:layout_height="117dp"
android:src="@drawable/logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyle"
android:layout_width="55dp"
android:layout_height="56dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/image"
app:layout_constraintVertical_bias="0.31" />
<Button
android:layout_width="147dp"
android:layout_height="70dp"
android:text="Stop"
android:id="@+id/but"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:backgroundTint="#FFC107"
app:layout_constraintTop_toBottomOf="@+id/progressBar2" />
<Button
android:layout_width="147dp"
android:layout_height="70dp"
android:text="Start"
android:id="@+id/but2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:backgroundTint="#FFC107"
app:layout_constraintTop_toBottomOf="@+id/progressBar2" />
</androidx.constraintlayout.widget.ConstraintLayout>
File one backend java file:
MainActivity.java:
package com.example.myapplicatio;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
public class MainActivity extends AppCompatActivity {
Button b1,bu2;
ProgressBar b2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 = findViewById(R.id.but);
b2 = findViewById(R.id.progressBar2);
bu2 = findViewById(R.id.but2);
bu2.setVisibility(View.INVISIBLE);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
b2.setVisibility(View.INVISIBLE);
b1.setVisibility(View.INVISIBLE);
bu2.setVisibility(View.VISIBLE);
}
});
bu2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
b2.setVisibility(View.VISIBLE);
bu2.setVisibility(View.INVISIBLE);
b1.setVisibility(View.VISIBLE);
}
});
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this,MainActivity2.class);
startActivity(intent);
finish();
}
},3000);
}
}
Second file :
Activity_main2.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".MainActivity2">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webs"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
Second file backend :
MainActivity.java:
package com.example.myapplicatio;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity2 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
WebView web ;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
web = findViewById(R.id.webs);
web.setWebViewClient(new WebViewClient());
web.loadUrl("https://www.google.com/");
}
}
Mainfeast.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplicatio">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar">
<activity
android:name=".MainActivity2"
android:exported="true" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Thankyou ........
Comments
Post a Comment