안드로이드 개발 질문/답변
(글 수 45,052)
------------------------------------------------------------------
<activity android:name=".AndstudyActivity"
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="AnotherActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
----------------------------------------------------------------
-anothermain.xml-
<EditText
android:id="@+id/inp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="UP EDIT!!"
/>
-----------------------------------
public class AndstudyActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
------------------------------------------------------------------
public class AnotherActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.anothermain);
Button btn = (Button)findViewById(R.id.inp);
}
}
검색해보니 남들은 findViewById 가 null 을 리턴한다는데 저는 실행중에 아예 죽어버리네요.
왜 그런건가요?? 런타임 에러가 나요.
그리고 한가지 궁금한게 메니페스트 보면 .AndstudyActivity 로 점이 찍혀있고, 또 AnotherActivity 엔 점을 안찍었습니다.
둘다 작동은 하는데 무슨 차이인가요? 점 찍고도 해보니까 되구요.
AnotherMain 은 버튼 눌렀을 때 다음과 같은 코드로 실행 되게 했습니다.
Intent act = new Intent(this, AnotherActivity.class); startActivityForResult(act, 1);




전체 문장이 코드화 되어버렸네요. 어떻게 고치는지 몰라서 냅둘게요. 부탁드려요 ㅜㅜ