Professional Documents
Culture Documents
PEMROGRAMAN MOBILE
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"
tools:context=".MainActivity">
<RelativeLayout
android:id="@+id/myRelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#48B1F2"
android:padding="6dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView"
android:layout_width="78dp"
android:layout_height="72dp"
app:srcCompat="@drawable/icon" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#48B1F2"
android:padding="6dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Menampilkan bil. ganjil genap dari
deret
array" android:textSize="10sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/npm"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/nama"
android:textSize="10sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/kelas"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
<TableLayout
android:id="@+id/body"
android:layout_below="@+id/profile"
android:layout_alignParentLeft="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="6dp"
android:paddingBottom="6dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="85dp"
android:layout_height="wrap_content"
android:text="Bilangan: " />
<EditText
android:id="@+id/ViewArray"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:textAlignment="textEnd" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="85dp"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:orientation="vertical">
<RadioGroup
android:id="@+id/radio"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radioGenap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bilangan Genap"
android:checked="true" />
<RadioButton
android:id="@+id/radioGanjil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bilangan Ganjil" />
</RadioGroup>
<Button
android:id="@+id/btnArray"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="12dp"
android:background="#F6F6F6"
android:text="Tampil Data"
android:padding="10dp"
android:layout_below="@+id/radio"
android:layout_alignRight="@+id/radio"
android:textColor="#000000" />
</RelativeLayout>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="85dp"
android:layout_height="wrap_content"
android:text="Hasil: " />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:orientation="vertical">
<EditText
android:id="@+id/ResultArray"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:textAlignment="textEnd" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total Deret = " />
<TextView
android:id="@+id/TotalArray"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Null" />
</LinearLayout>
</LinearLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.uts_iqbal;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Menampilkan Array
ViewArray = findViewById(R.id.ViewArray);
String resultviewArray = Arrayuts.ArrayutsView();
ViewArray.setText(resultviewArray);
// Hasil
ResultArray = findViewById(R.id.ResultArray);
String hasilArray = Arrayuts.ArrayutsGet((String)
radioSexButton.getText());
ResultArray.setText(hasilArray);
// Jumlah
TotalArray = (TextView)findViewById(R.id.TotalArray);
String totalArray = Arrayuts.ArrayutsTotal((String)
radioSexButton.getText());
TotalArray.setText(totalArray);
}
});
}
}
ArrayUTS
package com.example.uts_iqbal;
}
public String ArrayutsView(){
int i;
String viewarray = "";
for (i = 0; i < ArrayList.length; i++) {
viewarray = viewarray + " " +
String.valueOf(ArrayList[i]);
}
return viewarray;
}
Strings.xml
<resources>
<string name="app_name">UTS_IQBAL</string>
<string name="npm">NPM: 43A87006180178</string>
<string name="nama">NAMA: IQBAL FATHURROHMAN</string>
<string name="kelas">KELAS: S1/TI/07/K/P</string>
</resources>