Linear Layout Radio ( Android )

package Linear.Layout;

import java.util.RandomAccess;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.text.TextWatcher;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.EditText;

public class LinearLayoutRadioActivity extends Activity
implements RadioGroup.OnCheckedChangeListener{

RadioGroup orientation;
RadioGroup gravity;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

orientation=(RadioGroup)findViewById(R.id.orienation);
orientation.setOnCheckedChangeListener(this);
gravity=(RadioGroup)findViewById(R.id.gravity);
}

public void onCheckedChanged(RadioGroup group,int checkedId){
if( group==orientation){
if ( checkedId==R.id.horizontal){
orientation.setOrientation(LinearLayout.HORIZONTAL);
}
else{
orientation.setOrientation(LinearLayout.VERTICAL);
}
}
else if (group==gravity){
if(checkedId==R.id.left){
gravity.setGravity(Gravity.LEFT);
}
else if ( checkedId==R.id.center){
gravity.setGravity(Gravity.CENTER_HORIZONTAL);
}
else if(checkedId==R.id.right){
gravity.setGravity(Gravity.RIGHT);

}
}

}
}

Download projectnya di Sini

Advertisements

Published by

jarcode

hello I am jarcode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s