I am learning android and i am using android studio ver1.4.1.
I wanna use a Tabhost that has two tabs and each tab content is a class with a layout. but each time i debug the program i got this message :Unfortunately, information has stopped. please help me.
mainActivity.xml:
<TabHost
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tabs"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"></TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
</TabHost>
mainActivity.java:
public class ActivityMain extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity_main);
TabHost tabs = (TabHost) findViewById(R.id.tabs);
tabs.setup();
Intent intentPersonalInfo = new Intent().setClass(this,ActivityPersonalInfo.class);
TabHost.TabSpec spec1 = tabs.newTabSpec("tag1");
spec1.setContent(intentPersonalInfo).setIndicator("Personal Information");
tabs.addTab(spec1);
}
seccondActivity.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="48dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_alignBottom="#+id/textView"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/textView" />
</RelativeLayout>
seccondActivity.java:
public class ActivityPersonalInfo extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(activity_personal_info);
}
manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.miad.information" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name=".ActivityMain" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ActivityPersonalInfo"></activity>
</application>
Related
For some odd reason setContentView() is not calling my LoginActivity class. It displays the layout but doesn't read the context? I added a button and the onclicklistener and it isn't being called. Only the layout is being displayed.
This is quite bizarre I've seen to of done every single thing but the LoginActivity is being called? Is it because of the nested layout?
LoginActivity
public class LoginActivity extends BaseActivity implements View.OnClickListener {
#BindView(R.id.button_signin)
Button button_signin;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
//button_login.setOnClickListener(this);
button_signin.setOnClickListener(this);
}
#Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.button_signin:
Toast.makeText(this, "test321", Toast.LENGTH_SHORT).show();
break;
}
}
}
BaseActivity
public class BaseActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
}
XML
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="#color/ghostWhiteColor"
android:orientation="vertical"
android:context="test.testing.core.BaseActivity"
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/f_roboto_bold"
android:textColor="#color/holo_blue_light"
android:gravity="center"
android:paddingTop="140dp"
android:textSize="50sp"
android:text="#string/brandingtext" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="200dp">
<android.support.design.widget.TextInputLayout
android:id="#+id/input_login_username"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/login_username"
android:layout_width="285dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="text"
android:backgroundTint="#color/ghostWhiteColor"
android:hint="#string/hint_name"
android:singleLine="true"
android:textColor="#color/myBlack"
android:textColorHighlight="#color/antiqueWhiteColor"
/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/login_password"
android:layout_width="285dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="textPassword"
android:backgroundTint="#color/ghostWhiteColor"
android:hint="#string/hint_name"
android:singleLine="true"
/>
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/button_signin"
android:layout_width="125dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="#drawable/blue_oval"
android:text="#string/btn_login"
android:textColor="#color/ghostWhiteColor" />
<TextView
android:id="#+id/label_register"
android:layout_width="match_parent"
android:layout_height="60dp"
android:fontFamily="#font/f_roboto_lightitalic"
android:gravity="center"
android:text="hello321"
android:textColor="#color/myBlack"
android:textSize="#dimen/fui_heading_padding_bottom" />
</LinearLayout>
</RelativeLayout>
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.luxx.market.propg.luxx">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".BaseActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".core.activities.LoginActivity">
</activity>
<activity android:name=".core.activities.RegisterActivity">
</activity>
</application>
</manifest>
You are starting with BaseActivity which is incorrect, baseactivity should be an abstract class.
Put this inside your loginactivity and remove it from the baseactivity
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
I am a newbie in the android World and I am struggling with getting my camera to open on the click of a button in my app. I have followed several tutorials and still not managed to get it to work.
Finally I have come to a stage where I can run the app, and open the camera activity, but when I click the button to take a new picture my app fails.
I have tried various tutorials out now but just can't seem to make it work.
Can anyone tell me from my code below what I need to do to make this work?
I get the following errors:
java.lang.IllegalStateException: Could not find method dispatchTakePictureIntent(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'button_add_ph'
public class CameraActivity extends Activity {
ImageView result;
static final int REQUEST_IMAGE_CAPTURE = 1;
#Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.camera_activity);
result = (ImageView)findViewById(R.id.imageView1);
Button takePic = (Button)findViewById(button_add_ph);
}
public void dispatchTakePictureIntent(View view) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
result.setImageBitmap(imageBitmap);
}
}
and my xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginTop="15dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
android:id="#+id/imageView1"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:layout_marginTop="10dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/notes"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="Yo - no notes added for this photo this photo this photo this photo"
android:id="#+id/textView"
android:textSize="14dp"
android:layout_centerHorizontal="true"
android:maxLength="60"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button_edit"
android:text="edit note"
android:layout_below="#+id/textView"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/notes"
android:layout_marginTop="25dp">
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/button_add_note"
android:text="Add note"/>
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/button_delete"
android:text="Delete picture"/>
<Button
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/button_add_ph"
android:onClick="dispatchTakePictureIntent"
android:text="Take picture" />
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/backBtn"
android:onClick="buttonOnClick"
android:text="Hold dog mund"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"/>
</RelativeLayout>
</LinearLayout>
And my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.europcar.mob1exam">
<uses-feature android:name="android.hardware.camera2" android:required="true"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/iconfaetter"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<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=".CameraActivity">
</activity>
</application>
</manifest>
Thanks a lot in advance
I'm implementing an Android app for guitar chord recognition. My first layout xml is fine and it's updated, but when I click on login button it goes to next page and didn't show anything on it.
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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#drawable/background"
tools:context="com.example.guitarchordrecognition.MainActivity" >
<EditText
android:id="#+id/user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="86dp"
android:ems="10"
android:hint="#string/user" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/user"
android:layout_below="#+id/user"
android:layout_marginTop="30dp"
android:ems="10"
android:hint="#string/pass"
android:inputType="textPassword" />
<Button
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/password"
android:layout_alignRight="#+id/user"
android:layout_below="#+id/password"
android:layout_marginTop="41dp"
android:text="#string/login"
/>
</lativeLayout>
afterlogin.xml
<?xml version="1.0" encoding="utf-8"?>
<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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#drawable/background" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="116dp"
android:text="Button 1" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button1"
android:layout_centerVertical="true"
android:text="Button 2" />
</RelativeLayout>`
Mainactivity.java
public class MainActivity extends ActionBarActivity {
Button mybutton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mybutton = (Button)this.findViewById(R.id.login);
mybutton.setOnClickListener(new View.OnClickListener() {
private void buttonclick()
{
startActivity(new Intent("com.example.guitarchordrecognition.Afterlogin"));
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.login:
buttonclick();
break;
}
}
});
}
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.guitarchordrecognition"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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=".Afterlogin"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.guitarchordrecognition.Afterlogin" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
I don't know why you use action constructor, but this time
try startActivity(new Intent(MainActivity.this, Afterlogin.class)); instead.
I have three tabs (Tab1, tab 2, tab 3). I want starting the other activity all tabs.
I try the new intent in Tab 2.
My code this
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost tabHost=(TabHost)findViewById(R.id.tabHost);
tabHost.setup();
TabSpec spec1=tabHost.newTabSpec("Tab 1");
spec1.setContent(R.id.tab1);
spec1.setIndicator("Tab 1");
TabSpec spec2=tabHost.newTabSpec("Tab 2");
spec2.setIndicator("Tab 2", getResources().getDrawable(R.drawable.ic_launcher));
spec2.setContent(new Intent(this,teszt.class));
TabSpec spec3=tabHost.newTabSpec("Tab 3");
spec3.setIndicator("Tab 3");
spec3.setContent(R.id.tab3);
tabHost.addTab(spec1);
tabHost.addTab(spec2);
tabHost.addTab(spec3);
}
}
Manifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="hu.anzy.fulek.example.fulek.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=".teszt"
></activity>
</application>
Teszt.java
public class teszt extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.teszt_layout);
}
public void onClick(View v){
if (v.getId()== R.id.btnBackTo1){
Toast.makeText(this, "Click BackTo1", Toast.LENGTH_LONG).show();
} else
{
if (v.getId()== R.id.btnStart3) {
Toast.makeText(this, "Click Start3", Toast.LENGTH_LONG).show();
}
}
}
}
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/tabHost"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TabWidget
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#android:id/tabs"
/>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#android:id/tabcontent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/tab1"
android:orientation="vertical"
android:paddingTop="60px"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="100px"
android:text="This is tab1"
android:id="#+id/txt1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/tab2"
android:orientation="vertical"
android:paddingTop="60px"
>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/tab3"
android:orientation="vertical"
android:paddingTop="60px"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="100px"
android:text="This is tab 3"
android:id="#+id/txt3"
/>
</LinearLayout>
</FrameLayout>
</TabHost>
Test_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/btnBackTo1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Back to 1st Activity"
android:onClick="onClick"
/>
<Button
android:id="#+id/btnStart3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Start 3rd Activity"
android:onClick="onClick"
/>
</LinearLayout>
My application is runing but when I selected Tab 2 the application is stop.
What is the problem?
Ok I found the solution.
public class MainActivity extends TabActivity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
// Tab1
TabSpec spec1 = tabHost.newTabSpec("Tab1");
photospec.setIndicator("Tab1");
Intent aIntent = new Intent(this, aActivity.class);
photospec.setContent(aIntent);
// Tab2
TabSpec spec2 = tabHost.newTabSpec("Tab2");
songspec.setIndicator("Tab2");
Intent bIntent = new Intent(this, bActivity.class);
songspec.setContent(bIntent);
// Tab3
TabSpec spec3 = tabHost.newTabSpec("Tab3");
spec3.setIndicator("Tab3");
Intent cIntent = new Intent(this, cActivity.class);
spec3.setContent(cIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(spec1); // Adding tab
tabHost.addTab(spec2); // Adding tab
tabHost.addTab(spec3); // Adding tab
}
}
This aActivity similar bActivity and cActivity
import android.app.Activity;
import android.os.Bundle;
public class aActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.a_layout);
}
}
A_layout.xml similar B_layout.xml and C_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:text=" Text"
android:padding="15dip"
android:textSize="18dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hu.anzy.example.androidtablayoutactivity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="hu.anzy.example.MaintActivity"
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=".aActivity" />
<activity android:name=".bActivity" />
<activity android:name=".cActivity" />
</application>
</manifest>
i have been searching this site for an answer but i cant find one . my android app isnt swapping from portrait to landscape in my emulator it just shows a sideways portrait screen.
I have made a layout and layout-land folder with matching xml names and so on . but it doesnt seem to pick up on the layout-land versions. i do not have an onConfig() function or anything so i was wondering if anyone can help???
mainpage.xml layout-land
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/main_background"
android:gravity="center"
android:padding="30dip">
<TextView
android:id="#+id/main_title_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/main_title"
android:textColor="#color/text"
android:textSize="25sp" />
<TableLayout
android:id="#+id/tablelayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:stretchColumns="*">
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<Button
android:id="#+id/start_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/start_button"
android:textColor="#color/text" />
<Button
android:id="#+id/help_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/help_button"
android:textColor="#color/text" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent">
<Button
android:id="#+id/extra_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/extra_button"
android:textColor="#color/text" />
<Button
android:id="#+id/stop_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/stop_button"
android:textColor="#color/text" />
</TableRow>
</TableLayout>
</LinearLayout>
LAYOUT
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/main_background"
android:gravity="center"
android:padding="30dip">
<TextView
android:id="#+id/main_title_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/main_title"
android:textColor="#color/text"
android:textSize="25sp" />
<Button
android:id="#+id/start_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/start_button"
android:textColor="#color/text" />
<Button
android:id="#+id/help_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/help_button"
android:textColor="#color/text" />
<Button
android:id="#+id/extra_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/extra_button"
android:textColor="#color/text" />
<Button
android:id="#+id/stop_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/stop_button"
android:textColor="#color/text" />
</LinearLayout>
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MC.ChemPal"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".main"
android:label="#string/app_name">
<intent-filter>
<action android:name="com.MC.ChemPal.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".mainpage" android:label="#string/app_name">
<intent-filter>
<action android:name="com.MC.ChemPal.MAINPAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Extra"
android:label="#string/app_name">
<intent-filter>
<action android:name="com.MC.ChemPal.EXTRA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".help"
android:label="#string/app_name">
<intent-filter>
<action android:name="com.MC.ChemPal.HELP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".search_page"
android:label="#string/app_name">
<intent-filter>
<action android:name="com.MC.ChemPal.SEARCH_PAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
java
package com.MC.ChemPal;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class mainpage extends Activity {
/** Called when the activity is first created. */
Button start_button, help_button, extra_button, stop_button;
TextView display;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainpage);
start_button = (Button) findViewById(R.id.start_button);
help_button = (Button) findViewById(R.id.help_button);
extra_button = (Button) findViewById(R.id.extra_button);
stop_button= (Button) findViewById(R.id.stop_button);
display = (TextView) findViewById(R.id.main_title_text);
start_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent openSearchPage = new Intent("com.MC.ChemPal.SEARCH_PAGE");
startActivity(openSearchPage);
}
});
help_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent openHelp = new Intent("com.MC.ChemPal.HELP");
startActivity(openHelp);
}
});
extra_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent openExtra = new Intent("com.MC.ChemPal.EXTRA");
startActivity(openExtra);
}
});
stop_button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
onStop();
}
});
}
}
It is an emulator bug, when you try your activity start in landscape mode you will see that it will load mainpage.xml from layout-land ,
android:screenOrientation="landscape"
but ctrl+f12 doesnt work, it is a bug
http://code.google.com/p/android/issues/detail?id=13189