Hello I've got an app and I need help regarding ImageButton
.
Code:
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.social);
ImageButton img = (ImageButton) findViewById(R.id.imageView1);
img.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(social.this,facebook.class));
}
});
}
}
manifest file
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<activity
android:name=".MainActivity"
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="ana"></activity>
<activity android:name="facebook"></activity>
<activity android:name="instagram"></activity>
<activity android:name="pinterest"></activity>
<activity android:name="twitter"></activity>
<activity android:name="youtube"></activity>
<activity android:name="social"></activity>
</application>
</manifest>
Layout file
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignTop="@+id/imageButton1"
android:src="@drawable/fbf" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:src="@drawable/aas" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView1"
android:layout_alignTop="@+id/imageButton1"
android:src="@drawable/yoube" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton8"
android:layout_below="@+id/imageButton3"
android:layout_marginTop="19dp"
android:src="@drawable/ss" />
<ImageButton
android:id="@+id/imageButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton1"
android:layout_alignTop="@+id/imageButton4"
android:src="@drawable/mysp" />
<ImageButton
android:id="@+id/imageButton6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton2"
android:layout_alignTop="@+id/imageButton7"
android:src="@drawable/sc" />
<ImageButton
android:id="@+id/imageButton7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton5"
android:layout_below="@+id/imageButton5"
android:layout_marginTop="14dp"
android:src="@drawable/tumblr" />
<ImageButton
android:id="@+id/imageButton8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton3"
android:layout_alignTop="@+id/imageButton7"
android:src="@drawable/justinlogo" />
<ImageButton
android:id="@+id/imageButton9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton2"
android:layout_alignTop="@+id/imageButton5"
android:src="@drawable/insta" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageButton6"
android:layout_below="@+id/imageButton6"
android:layout_marginTop="24dp"
android:src="@drawable/fbf" />
What I want to do is, when i click the ImageButton it should open facebook
class. I made it with normal button but, unlike normal button, its not working with ImageButton.
Its giving error "application stopped" ! someone help me ? Thanks all.
**LOGCAT REPORT **