Nama : Ady Nugraha
Kelas : 06TPLP001
Tugas Ujian Tengah Semester Mobile Programing
DESKRIPSI
Disini saya akan menampilkan program mobile beranda dengan Tap Post yang terdiri dari Log In, Beranda, dan Contact Us.
Berikut tampilan setelah di aplikasikan di handphone
Tampilan Log In:
Tampilan Home dan About
Kelas : 06TPLP001
Tugas Ujian Tengah Semester Mobile Programing
DESKRIPSI
Disini saya akan menampilkan program mobile beranda dengan Tap Post yang terdiri dari Log In, Beranda, dan Contact Us.
Tampilan Log In:
Tampilan Home dan About
Source Coding:
activity_main.xml (Login)
<?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="@android:color/black"
tools:context=".MainActivity">
<TextView
android:id="@+id/tv_username"
android:background="@drawable/tfrounded"
android:layout_width="245dp"
android:layout_height="40dp"
android:ems="10"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="400dp"
/>
<TextView
android:id="@+id/tv_password"
android:background="@drawable/tfrounded"
android:layout_width="245dp"
android:layout_height="40dp"
android:ems="10"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="parent"
android:layout_marginTop="460dp"
app:layout_constraintTop_toTopOf="parent"/>
<EditText
android:id="@+id/et_username"
android:layout_width="210dp"
android:layout_height="40dp"
android:layout_marginTop="400dp"
android:textColor="#fff"
android:background="@drawable/loginrounded"
android:ems="10"
android:fontFamily="@font/poppins_medium"
android:hint="Username"
android:inputType="textPersonName"
android:textColorHint="#7a7778"
android:textSize="14dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button"
android:layout_width="245dp"
android:layout_height="50dp"
android:layout_marginTop="540dp"
android:background="@drawable/btnlogin"
android:fontFamily="@font/poppins_semibold"
android:text="Log In"
android:textAllCaps="false"
android:textColor="#000"
android:textSize="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/et_password"
android:layout_width="210dp"
android:layout_height="40dp"
android:layout_marginTop="460dp"
android:background="@drawable/loginrounded"
android:inputType="textPassword"
android:ems="10"
android:fontFamily="@font/poppins_medium"
android:hint="Password"
android:textColorHint="#7a7778"
android:textSize="14dp"
android:textColor="#fff"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<ImageView
android:id="@+id/imageView"
android:layout_width="349dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_height="300dp"
android:layout_marginTop="50dp"
app:srcCompat="@drawable/adykontol"
tools:layout_editor_absoluteX="46dp"
tools:layout_editor_absoluteY="-122dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
======================================================
MAINACTIVITY.JAVA
package com.example.utsady2;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.utsady2.R;
public class MainActivity extends AppCompatActivity {
TextView uname,pass;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
uname = (TextView) findViewById(R.id.et_username);
pass = (TextView) findViewById(R.id.et_username);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(uname.getText().toString().equals("ady") && pass.getText().toString().equals("ady"))
{
Toast.makeText(getApplicationContext(),
"Redirecting...",Toast.LENGTH_SHORT).show();
Intent iLogin = new Intent(getApplicationContext(), inti.class);
startActivity(iLogin);
}
else
{
Toast.makeText(getApplicationContext(),
"Username atau Password salah..",Toast.LENGTH_SHORT).show();
uname.setText("");
pass.setText("");
}
}
});
}
}
==========================================================================
activity_inti.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=".MainActivity">
<View
android:id="@+id/view"
android:layout_width="wrap_content"
android:layout_height="150dp"
android:background="@drawable/topinti"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TabHost
android:layout_width="357dip"
android:layout_height="fill_parent"
android:layout_marginTop="94dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="parent"
android:id="@+id/tabHost1"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_marginLeft="100dp"
android:layout_marginTop="100dp"
android:textColor="#8080"
android:id="@+id/textView2"
android:textSize="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bagian Home" />
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView3"
android:layout_marginLeft="100dp"
android:layout_marginTop="100dp"
android:textColor="#8080"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bagian About"
android:textSize="20dp"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</androidx.constraintlayout.widget.ConstraintLayout>
========================================================
inti.java
package com.example.utsady2;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TabHost;
import com.example.utsady2.R;
public class inti extends Activity {
TabHost tabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inti);
TabHost tabHost = (TabHost) findViewById(R.id.tabHost1);
tabHost.setup();
TabHost.TabSpec spec;
TabHost.TabSpec spec1;
spec1 = tabHost.newTabSpec("tabone").setIndicator("Home").setContent(R.id.tab1);
tabHost.addTab(spec1);
spec = tabHost.newTabSpec("tabtwo").setIndicator("About").setContent(R.id.tab2);
tabHost.addTab(spec);
}
}



Komentar
Posting Komentar