Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old December 11th, 2010, 04:06 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2010
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default unable to switch activity

Hi,
I am new to android development. I am facing problem in switching between activities. I am attaching the code files ... Please help me solve this problem

Main Activity:
Code:
package swz.pkg;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class SWMainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button btnMSrch = (Button) findViewById(R.id.btnClosetSearch);
        
        try{
        btnMSrch.setOnClickListener(new View.OnClickListener() {
        	public void onClick(View v) {
        	Intent myIntent = new Intent(v.getContext(),ClosetSearchAct.class); 
        	startActivityForResult(myIntent,0); 
        	}

        	}); 
        	}
        	catch (Exception ex)
        	{
        		System.out.println("---------------------******------------------------");
        		ex.printStackTrace();
        		System.out.println();
        		System.out.println("---------------------******------------------------");
        	} 

        
    }
}

main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>

<Button
android:id="@+id/btnMeasurementSearch"
android:layout_width="fill_parent"
android:layout_height="150px"
android:background="#ffffffff"
android:text="Measurement Search"
android:textSize="26sp"
android:typeface="serif"
android:textStyle="bold"
android:textColor="#ff8c2528"
android:layout_x="0px"
android:layout_y="47px"
>
</Button>
<Button
android:id="@+id/btnClosetSearch"
android:layout_width="fill_parent"
android:layout_height="150px"
android:text="Closet Search"
android:textSize="26sp"
android:typeface="serif"
android:textStyle="bold"
android:textColor="#ff462556"
android:layout_x="0px"
android:layout_y="213px"
>
</Button>


</AbsoluteLayout>

closetSearch activity(The next activity I want to move to):
Code:
package swz.pkg;

import android.app.Activity;
import android.os.Bundle;

public class ClosetSearchAct extends Activity {
	public void onCreate(Bundle savedInstanceState) {
	setContentView(R.layout.closetsearchact);
    
	}
}


closetsearchact.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<Spinner
android:id="@+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="0px"
android:layout_y="33px"
>
</Spinner>
<Spinner
android:id="@+id/spinner2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="0px"
android:layout_y="101px"
>
</Spinner>
<Spinner
android:id="@+id/spinner3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="0px"
android:layout_y="173px"
>
</Spinner>
<ImageButton
android:id="@+id/btnReg"
android:layout_width="128px"
android:layout_height="wrap_content"
android:src="@drawable/reg"
android:layout_x="151px"
android:layout_y="279px"
>
</ImageButton>
<ImageButton
android:id="@+id/btnSearch"
android:layout_width="114px"
android:layout_height="49px"
android:src="@drawable/search"
android:layout_x="37px"
android:layout_y="279px"
>
</ImageButton>
</AbsoluteLayout>


AndroidManifest.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="swz.pkg"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".SWMainActivity"
                  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=".ClosetSearchAct" android:label="@string/app_name"> </activity>
		
        

    </application>


</manifest>

Advertisements
adilshoukat is offline  
Reply With Quote
sponsored links
Reply
Tags
activity


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:23 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.