2011-09-29 9 views
0

나는 상자에 당신의 이름을 쓰고 ok를 클릭하면 새 페이지가 당신의 이름을 보여줄 것입니다. 문제는 ok를 클릭해도 아무 일도 일어나지 않는다는 것입니다. 여기 매니페스트안드로이드에서 두 가지 활동 연결하기

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="edu.calpoly.android.lab1Sada" 
    android:versionCode="1" 
    android:versionName="1.0"> 
    <uses-sdk android:minSdkVersion="4" /> 

    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".Click" 
       android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity android:name="HelloWorld" ></activity> 

    </application> 
</manifest> 

public class Click extends Activity implements OnClickListener{ 

     @Override 
     public void onClick(View v) { 
       // TODO Auto-generated method stub 
       String TypedText = (String)MyText.getText().toString(); 
       Intent MyInt = new Intent(this, HelloWorld.class); 
       MyInt.putExtra("user", TypedText); 
       this.startActivity(MyInt);  
       Bundle Retrive = this.getIntent().getExtras(); 
       Retrive.getString("user"); 
       setContentView(R.id.Text); 
       TextView TextV = (TextView)findViewById(R.id.Text); 
       TextV.setText("user");     

     } 
     android.widget.EditText MyText; 

     public void OnCreate (Bundle savedInstanceState){ 
       super.onCreate(savedInstanceState); 
       this.setContentView(R.layout.name_getter); 
       MyText = (EditText)this.findViewById(R.id.editText1); 
       this.findViewById(R.id.button1); 
       android.widget.Button RefBut = (Button)this.findViewById(R.id.button1); 
       RefBut.setOnClickListener(this); 

       } 

다음은 주요 활동

그리고 첫 번째 활동 클릭을 시작합니다하지만 앱이 새로운보기를 표시하지 않는 안드로이드 에뮬레이터를 시작 ...

+1

HelloWorld 활동을위한 코드? –

+0

당신은 단지 안드로이드의 "의도"개념을 이해해야합니다. –

+0

@RahulChoudhary Eclipse에서 새로운 Android 프로젝트를 시작하는 간단한 Helloworld 클래스입니다. –

답변

1

내가하는 일을 알고 있지만 이런 식으로 다른 활동으로 데이터를 보내거나 가져올 수 있습니다 :

Intent의 개념을 이해해야합니다. 두 번째 활동에서

Intent i = new Intent(this, ActivityTwo.class); 
i.putExtra("name", "paresh"); 
i.putExtra("technology", "android"); 
startActivity(i); 

: 첫 번째 활동에서

Android Intents

0

당신은 통과해야합니다 : 참조 용 아직

Bundle extras = getIntent().getExtras(); 
if (extras == null) { 
    return; 
} 
String strName = extras.getString("name"); 
String strTechnology = extras.getString("technology"); 

, 여기에 기사가 동일에 대한 자세한 내용을 알고있다 활동 1의 텍스트를 읽고 활동 2의 묶음으로받습니다.

안드로이드 용 첫 번째 튜토리얼로 helloworld 프로그램을 살펴보십시오.

활동을 연장하면됩니다. 수퍼 클래스의 전체 패키지는 말할 필요가 없습니다.

관련 문제