Persegi di Android ( Android )

package Persehi.aerdy;

import android.app.Activity;
import android.os.Bundle;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class PeregiActivity extends Activity implements TextWatcher{
/** Called when the activity is first created. */
private AutoCompleteTextView txtPanjang;
TextView selection;
private EditText txtLuas;
private Button btnHitung;
String[] items={“22”, “ipsum”, “dolor”, “sit”, “amet”,
“consectetuer”, “adipiscing”, “elit”, “morbi”, “vel”,
“ligula”, “vitae”, “arcu”, “aliquet”, “mollis”,
“etiam”, “vel”, “erat”, “placerat”, “ante”,
“porttitor”, “sodales”, “pellentesque”, “augue”, “purus”};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txtPanjang = (AutoCompleteTextView)findViewById(R.id.txtPanjang);
selection=(TextView)findViewById(R.id.selection);
txtLuas = (EditText) findViewById(R.id.txtLuas);
btnHitung = (Button) findViewById(R.id.btnHitung);

txtPanjang.addTextChangedListener(this);
txtPanjang.setAdapter(new ArrayAdapter(this,
android.R.layout.simple_dropdown_item_1line,
items));

}
public void hitungLuas( View view){
try{
int panjang=Integer.parseInt(txtPanjang.getText().toString());
//int panjang=Integer.parseInt(txtPanjang.getText().toString());

if(panjang==22){

// int luas =panjang*lebar;
txtLuas.setText(String.valueOf(“virgo”));

}
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub

}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub

}
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub

}
}

Download Project nya 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