틀림
package com.gusfree.gallery; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.widget.Gallery; public class GalleryActivity extends Activity { Gallery gallery=null; int[] datas; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); gallery=(Gallery)this.findViewById(R.id.gallery1); setContentView(R.layout.main); //nullPointException 발생 합니다. gallery.setBackgroundColor(Color.BLUE); } }
package com.gusfree.gallery; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.widget.Gallery; public class GalleryActivity extends Activity { Gallery gallery=null; int[] datas; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); gallery=(Gallery)this.findViewById(R.id.gallery1); gallery.setBackgroundColor(Color.BLUE); } }
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.gusfree.gallery" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".GalleryActivity1" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.gusfree.gallery" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".GalleryActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
'Android > 2012.04월 강좌' 카테고리의 다른 글
4일차 gallery2 (0) | 2012.05.01 |
---|---|
4일차 gallery (0) | 2012.05.01 |
4일차 ImageList (textView->imageView->button-> text(Toast)출력) (0) | 2012.05.01 |
4일차 ImageList (SimpleAdapter, HashMap) (2) | 2012.05.01 |
4일차 ImageList (super class사용하는법) (0) | 2012.05.01 |