Skip to content

Instantly share code, notes, and snippets.

View gmsetiawan's full-sized avatar
💭
Friendly

Gunamullia Setiawan gmsetiawan

💭
Friendly
  • DroidClass
  • Indonesian
View GitHub Profile
package com.example.droidclass;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
package com.example.droidclass;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.droidclass.MainActivity"
tools:ignore="MergeRootFrame" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
package com.example.droidclass;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class FormWidgetActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
public class FormWidgetActivity extends Activity{
TextView tvFirst;
Button btnClick;
String a = "HelloWorld";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
final ToggleButton tB = (ToggleButton) findViewById(R.id.toggleButton1);
final TextView tBStatus = (TextView) findViewById(R.id.textView2);
tB.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
boolean on = tB.isChecked();
if (on) {
tBStatus.setText("On");
// Radio Button Group - Gender
RadioGroup rgGender = (RadioGroup) findViewById(R.id.radioGroup1);
RadioButton rbMale = (RadioButton) findViewById(R.id.radio0);
RadioButton rbFemale = (RadioButton) findViewById(R.id.radio1);
rgGender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
if (checkedId == R.id.radio0) {
Spinner spinFromString = (Spinner) findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter =
ArrayAdapter.createFromResource(FormWidgetActivity.this,
R.array.country_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinFromString.setAdapter(adapter);
spinFromString.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
Spinner spinFromList = (Spinner) findViewById(R.id.spinner2);
List<String> list = new ArrayList<String>();
list.add("Indonesia");
list.add("England");
list.add("USA");
list.add("Franch");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinFromList.setAdapter(dataAdapter);