Problem with activity group

by Laxmi Verma » Tue, 05 Apr 2011 00:03:07 GMT


Sponsored Links
 Hi,

I am using ActivityGroup class for one of my tab in my application.

1) There is a tab activity class calling the activitygroup class.

2) In activity group class i am calling one activity say Activity A which is
a list view.

3) On Activity A item click, I am calling another activity say Activity B.

I need to override the back button functionality in Activity A and Activity
B.

The problem which I am facing is on Activity A it is successfuly calling the
overriden onBackButton method but on Activity B instead of overriding the
back button method, it is calling the Tab Activity's back button method.  I
am not sure why?
I even debugged the code and it never goes into the onbackbutton method of
Activity B.

To resolve this I even tried calling Activity A on back button press of tab
activity which is required.  But the flow come as it goes into activity A
and then from there it goes directly to the First Activity.

I am also using Alert Dialog Box in both of the activity and passing
getParent() as context in the Alert Builder Dialog Box.

Any help in this regard will be great.


Thanks & Regards,
Laxmi Verma

-- 



Re: Problem with activity group

by TreKing » Tue, 05 Apr 2011 01:01:53 GMT


 On Mon, Apr 4, 2011 at 11:03 AM, Laxmi Verma





That's a problem in and of itself. From what I've read around here,
ActivityGroup is pretty much a hack. Use Views in your Tabs or try the new
fragment stuff.

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

-- 


Sponsored Links


Re: Problem with activity group

by Laxmi Verma » Tue, 05 Apr 2011 13:20:57 GMT


 Hi,

Can you please detail out about your reply.  I am unable to understand it.
Is there any other option available instead of ActivityGroup to change the
views in the tab.
If yes, then please provide some link or some code example on it.

Thanks!!






-- 



Re: Problem with activity group

by TreKing » Tue, 05 Apr 2011 23:42:13 GMT


 On Tue, Apr 5, 2011 at 12:20 AM, Laxmi Verma




Yes, use Views or Fragments, as I said.



Look through the documentation for TabView or Fragment. You should find
plenty of info.

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

-- 



Other Threads

1. Gallery view problems - external memory

Hi all,

I have developed a very simple gallery (it started as the hello
gallery example) where I have added code to get the images from the
content provider.  It should return all images from the SD card but it
is returning no images, my gallery view is blank. I am a fairly new
developer, just working my way around the tutorials online. Here is
the code.

package com.tutorials;

import java.util.ArrayList;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore.Images.Media;
import android.provider.MediaStore.Images.Thumbnails;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Toast;

public class HelloGallery extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Gallery g = (Gallery)findViewById(R.id.gallery);
        g.setAdapter(new ImageAdapter(this));

        g.setOnItemClickListener(new OnItemClickListener(){
                public void onItemClick(AdapterView parent, View v, int
position, long id){
                        Toast.makeText(HelloGallery.this,"" + position,
Toast.LENGTH_SHORT).show();
                }
        });
    }

    public class ImageAdapter extends BaseAdapter{
        int mGalleryItemBackground;
        private Context mContext;

        //get images from phone

        public ArrayList<Uri> getImageTable(){
                ArrayList<Uri> arrayList = new ArrayList<Uri>();
                try{

                ContentResolver cr = getContentResolver();

                String imageId = Media._ID;
                Toast toast =
Toast.makeText(mContext,imageId,Toast.LENGTH_LONG);
                toast.show();
                String [] images = new String[]{imageId};

                //Get Uri of ContentProvider MediaStore.Images.ImageColumns
                Uri mediaUri = Thumbnails.EXTERNAL_CONTENT_URI;

                Cursor managedCursor = managedQuery(mediaUri, images, null,
null, null);

                startManagingCursor(managedCursor);
                int columnIndex = managedCursor.getColumnIndexOrThrow(imageId);

                for(int i=0;i<managedCursor.getCount();i++){
                        managedCursor.moveToPosition(i);
                        int id = managedCursor.getInt(columnIndex);
                        arrayList.add(Uri.withAppendedPath(mediaUri, "" + 
imageId));
                }

                }catch(Exception e){
                        Toast toast =
Toast.makeText(mContext,e.toString(),Toast.LENGTH_LONG);
                        toast.show();
                }
                return arrayList;
        }



        public ImageAdapter(Context c){
                mContext = c;
                TypedArray a = obtainStyledAttributes(R.styleable.HelloGallery);
                mGalleryItemBackground = a.getResourceId(
                                
R.styleable.HelloGallery_android_galleryItemBackground, 0);
                a.recycle();
        }

                @Override
                public int getCount() {
                        // TODO Auto-generated method stub
                        return 0;
                }

                @Override
                public Object getItem(int position) {
                        // TODO Auto-generated method stub
                        return position;
                }

                @Override
                public long getItemId(int position) {
                        // TODO Auto-generated method stub
                        return position;
                }

                @Override
                public View getView(int position, View convertView, ViewGroup
parent) {
                        // TODO Auto-generated method stub
                        ImageView i = new ImageView(mContext);

                        //i.setImageResource(mImageIds[position]);
                        i.setImageURI(getImageTable().get(position));
                        i.setLayoutParams(new Gallery.LayoutParams(150, 100));
                        i.setScaleType(ImageView.ScaleType.FIT_XY);
                        i.setBackgroundResource(mGalleryItemBackground);

                        return i;
                }

    }

 }


-- 

2. X Axis Sensor Correction - Flipped Sensor Detection - Froyo

We are trying to determine the best way to patch InputDevice.java to
correct a sensor issue. The touchscreen is detecting the location
opposite of the pressure. For instance, to unlock the device, I have
to put my finger in the exact spot on the left side of the screen for
it to register on the right side. The same thing happens for buttons,
press right to touch the left button, and vice versa. We thought it
might be possible to half the absolute value, but that may not work as
the absX range is 0-4095. From debug:

Left Side
D/InputDevice( 1062): reportData[j + MotionEvent.SAMPLE_X] = 3708.0
D/InputDevice( 1062): absX.minValue  = 0
D/InputDevice( 1062): absX.range  = 4095
D/InputDevice( 1062): w  = 799
D/InputDevice( 1062): reportData[j + MotionEvent.SAMPLE_X] = 3711.0
D/InputDevice( 1062): absX.minValue  = 0
D/InputDevice( 1062): absX.range  = 4095
D/InputDevice( 1062): w  = 799

Right Side
/InputDevice( 1062): reportData[j + MotionEvent.SAMPLE_X] = 256.0
D/InputDevice( 1062): absX.minValue  = 0
D/InputDevice( 1062): absX.range  = 4095
D/InputDevice( 1062): w  = 799

Would adjusting currentmove be the place? or is there a better way to
correct this issue in Froyo?

-- 

3. How to programatically Pan one image over another using a seekbar to control Pan?

4. SMS Sent but Not Received

5. onPrepareDialogBuilder, onClick & setItemChecked for multi choice

6. Launch camera app with an intent?

7. TextView height not collapsing