안녕하세요 여러분 께 확인란과 적용 버튼이 있습니다. 그래서 어떤 사람이 체크 박스를 체크하지 않고 적용 버튼을 클릭하면 건배 메시지를 주어야하고 체크 박스를 체크하고 적용시 onclick하면 다음 활동으로 넘어갑니다. 이것은 내 코드입니다. 내가 안드로이드에 새로운 오전 나누었다이 질문은 바보 이었나 수정하시기 바랍니다 수체크 박스가 선택되지 않고 버튼이 클릭되면 토스트 메시지가 표시됩니다.
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:orientation="vertical"
android:background="#A9F5F2">
<TextView
android:id="@+id/topic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="22sp"
android:text="@string/topic" />
<ScrollView
android:id="@+id/Scrolly"
android:layout_width="275dp"
android:layout_height="200dp"
android:layout_below="@id/topic"
android:isScrollContainer="true"
android:fadingEdgeLength="14.5sp"
android:focusable="true">
<LinearLayout
android:layout_width="275dp"
android:layout_height="200dp" >
<TextView
android:id="@+id/rules"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textSize="22sp"
android:text="@string/rules" />
</LinearLayout>
</ScrollView>
<CheckBox
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Scrolly"
android:layout_below="@+id/Scrolly"
android:layout_marginTop="8dp"
android:text="@string/check" />
<Button
android:id="@+id/Apply"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/check"
android:layout_below="@+id/check"
android:layout_marginTop="32dp"
android:background="#3b5998"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:text="@string/after"
android:textColor="#ffffff"
android:textStyle="bold" />
</RelativeLayout>
MainActvity.java
package com.meti.workforhome;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button mApply = (Button) findViewById(R.id.Apply);
final CheckBox checkBox = (CheckBox) findViewById(R.id.check);
mApply.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
if (checkBox.isChecked()) {
// TODO Auto-generated method stub
String clicks = "click";
String message = "Apply button clicked";
Log.i(clicks, message);
Intent i = new Intent(MainActivity.this, FormActivity.class);
startActivity(i);
}
else
{
Toast.makeText(this.getApplicationContext(), R.string.notice, Toast.LENGTH_LONG).show();
}
}
private Context getApplicationContext() {
// TODO Auto-generated method stub
return null;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
activity_main.xml 나는 사전에 잘못 .Thanks을 간다하고있다.
을 사용할 수 있습니다하지만 문제는 무엇
이그냥
또는
을 사용하여 제거? – nKn