so here's what i need : first page -> linked to second page (with several image button) -> linked to different third page.
now i have tried the "first page -> linked to second page" stage.
activity_main.xml :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textSize="20sp"
android:text="This is first activity" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:text="Move to second activity" />
</RelativeLayout>
MainActivity.java :
package com.example.acer.myapplication;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
Button buttoon;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Intent move= new Intent(this, ActivityTwo.class);
buttoon=(Button) findViewById(R.id.button1);
buttoon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(move);
}
});
}
}
ActivityTwo.java :
package com.example.acer.myapplication;
import android.os.Bundle;
import android.app.Activity;
public class ActivityTwo extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_two);
}
}
it is actually working when the second page DID NOT contained any image button.
activity_two.xml (WORKING) :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="92dp"
android:text="Second activity"
android:textSize="20sp" />
</RelativeLayout>
button without any image is also WORKING :
<Button
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Second activity" />
but when you added image, it's just not working.
using button with background image (NOT WORKING):
<Button
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Second activity"
android:background="@drawable/image"/>
using image button (NOT WORKING):
<ImageButton
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Second activity"
android:src="@drawable/image"/>
and i really need for the second page to have image button. please enlighten me where am i wrong or is there another trick.
ps : when i say not working i mean it build smoothly but it just forced closed in the android phone when the intent is called. so no logcat entries.