-3
我是新來的android和我正在一個應用程序,我需要顯示一個電子郵件編輯文本字段與2個按鈕提交和取消,當我點擊忘記密碼按鈕,它應該顯示在它下面。任何人都可以請幫助我的XML佈局信息和Java以及。提前感謝和感謝。顯示電子郵件編輯文本字段與按鈕提交和取消點擊忘記密碼按鈕
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/LoginLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="center_horizontal"
android:orientation="vertical" >
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginTop="21dp"
android:background="@drawable/rounders_fpass"
android:ems="10"
android:hint="PASSWORD"
android:inputType="textPassword"
android:paddingLeft="10dp" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="41dp"
android:background="@drawable/rounders_email"
android:ems="10"
android:hint="EMAIL ID"
android:inputType="textEmailAddress"
android:paddingLeft="10dp" />
<Button
android:id="@+id/button_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/editText2"
android:layout_marginTop="25dp"
android:gravity="center"
android:text="LOGIN" />
<Button
android:id="@+id/fp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Forgot Password?" />
<TextView
android:id="@+id/appear"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_below="@+id/fp"
android:layout_centerHorizontal="true"
android:layout_marginTop="36dp"
android:text="APPEAR" />
</RelativeLayout>
</RelativeLayout>
JAVA:
public class Login extends Activity {
Button log, fp;
TextView forgot;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
// views
views();
// clicklistener
setClickListenerOnButton_log();
setClickListenerOnButton_fp();
}
private void setClickListenerOnButton_fp() {
// TODO Auto-generated method stub
fp.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
setContentView(forgot);
forgot.setVisibility(View.VISIBLE);
}
});
}
private void views() {
// TODO Auto-generated method stub
log = (Button) findViewById(R.id.button_login);
fp = (Button) findViewById(R.id.fp);
forgot = (TextView) findViewById(R.id.appear);
}
private void setClickListenerOnButton_log() {
// TODO Auto-generated method stub
log.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(Login.this, MainActivity.class));
}
});
}
}
顯示你的佈局文件 –
@NoName他說想知道XML佈局信息和Java以及意味着勺子餵養... – duggu
檢查[官方文檔](http://developer.android.com/reference/android/ widget/package-summary.html)並嘗試首先探索自己。 –