2014-07-26 7 views
0

기본적으로 원하는 것은 : 버튼을 클릭하면 "아니오"라고 대답 할 때 빈 텍스트보기가 "왜?"로 변경되기를 원합니다. 그런 다음 편집 텍스트 상자에 이유를 입력 할 수 있습니다. 마지막 클래스는 모든 문제를 나열 할 수 있습니다. 기계적 인조 인간.다른 클래스의 목록에 EditText를 어떻게 설정합니까?

package com.toc.maintenance; 

import java.text.SimpleDateFormat; 
import java.util.Calendar; 

import android.annotation.SuppressLint; 
import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.TextView; 

public class Safety extends Activity { 
Button yes, No, NA, done; 

TextView display; 

@SuppressLint("SimpleDateFormat") 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    this.setContentView(R.layout.safety); 
    No = (Button) findViewById(R.id.bNo); 
    yes = (Button) findViewById(R.id.bYes); 
    display = (TextView) findViewById(R.id.textView2); 
    SimpleDateFormat dateFormat = new SimpleDateFormat(
      "yyyy/MM/dd HH:mm:ss"); 
    Calendar cal = Calendar.getInstance(); 
    String starttime = dateFormat.format(cal.getTime()); 

    Intent i = new Intent(getApplicationContext(), Report.class); 
    i.putExtra("starttime", starttime); 

    yes.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      Intent Safety1 = new Intent(getApplicationContext(), 
        Safety1.class); 
      startActivity(Safety1); 

     } 

    }); 
    NA = (Button) findViewById(R.id.bNA); 

    NA.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      Intent Safety1 = new Intent(getApplicationContext(), 
        Safety1.class); 
      startActivity(Safety1); 

     } 
    }); 

    No.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      display.setText("Why?"); 
     } 

    }); 
    done.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 

//here (at done button)is where I want to capture the editText for the final class 
//"Report". I have an editBox with "@+id/explain" tag. 
//But I am going to keep on adding text throughout the app. 
//I've tried a setText, super, etc. But I just can't get it right. Thanks in advance. 
     } 

    }); 

} 

} 당신이 다음 클래스에서 활동을 의미하는 경우

+0

예 또는 아니요로 버튼을 사용하고 버튼을 눌렀을 때 .setText를 사용하여 종료되었습니다. 훨씬 쉬워졌습니다. – George

답변

0

, 당신은 EditTextInstance.getText()을 사용할 수 있습니다 그리고 당신은 '생성자를 사용하여'(intent.putExtra()을 통해)이 다른 활동에 문자열을 반환 통과 또는 클래스 수 있습니다.

0

putExtra()를 사용하여 "WHY?" 또는 뭔가. getString()을 사용하여 검색하십시오.

관련 문제