- 화면에 질문을 남기면서 질문에 대한 답을하게됩니다 A 버튼을 표시하는
- 미리 정의 된 질문을 제시 할 영역을 클릭
- 대답을 표시 할 영역
- 다음 질문과 함께이 화면과 동일한 형식으로 변환되는 버튼
- 앱을 끝내게하는 버튼 (a (3)으로의 천이)
버튼 클릭만으로 다른 질문/답변 쌍으로 작동하려면 화면 1에서 화면 2로 전환하려고 시도하십시오. 오류가있는 화면과 활동을 전환하는 것 이외에 다른 작업을 수행하려는 경우 알려주십시오. (넣다 필요)불행하게도 버튼 작동이 중지되었습니다 (프로젝트 이름)
package com.example.androidassignment2;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
public class AndroidAssignment2 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_android_assignment2_1);
Button next = (Button) findViewById(R.id.QButton);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.android_assignment2_1, menu);
return true;
}
}
레이아웃 파일
<LinearLayout 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:orientation="vertical" >
<TextView android:id="@+id/Questions"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:text="@string/Q2" />
<Button android:id="@+id/QButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_question" />
<Button android:id="@+id/AButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />
<TextView android:id="@+id/Answers"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:hint="@string/A2" />
<Button android:id="@+id/QuitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_quit" />
</LinearLayout>
활동 한 파일은
package com.example.androidassignment2;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button next = (Button) findViewById(R.id.QButton);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), AndroidAssignment2_1.class);
startActivityForResult(myIntent, 0);
}
});
}
@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;
}
}
당신은 새로운 활동을 시작
항상 게시하시기 바랍니다 로그 캣 스택 추적을 사용하는 것입니다. 어떻게하는지 모르면 물어보십시오. – Simon