ok If this is the case then you can implement the "Back" key in your
code as:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
// your implementation
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}
or if you are using API 8
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
}
On Nov 30, 2:27 pm, MaheshSharma <[email protected]>
wrote:
> Yes, I have done that.
>
> The problem is that I will have to add manually add this PlayBack
> custom layout to each of the view.
>
> Now more over, even if I do that, For each new instantiation of view,
> I have to do bunch of instiations. Like connecting to background
> service. Which is costly.
>
> So I was wondering, If I could have to inflate it only once.
>
> On Nov 30, 11:57 am, akkilis <[email protected]> wrote:
>
> > To add on, dont forget to add the constructor to the PlayBackView with
> > context and AttributeSet
>
> > i.e.
>
> > public PlayBackrView(Context context, AttributeSet attrs) {
> > super(context, attrs);
> > ......
> > ......
> > }
>
> > On Nov 30, 11:52 am, akkilis <[email protected]> wrote:
>
> > > Mahesh,
>
> > > Why dont you make a different class, say PlayBackView, extending
> > > LinearLayout and place the layout of the common component "Playback
> > > bar" in a different layout xml, say playback.xml.
>
> > > Now inflate the playback.xml in the PlayBackView.
>
> > > Now you can add this your custom view in any of the layout xml (home,
> > > A, B, C)
> > > as:
>
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <FrameLayout xmlns:android="http://schemas.android.com/apk/res/
> > > android"
> > > android:orientation="vertical" android:layout_width="fill_parent"
> > > android:layout_height="fill_parent">
> > > <com.packagename.PlayBackView
> > > android:id="@+id/playbackview"
> > > android:layout_width="match_parent"
> > > android:layout_height="wrap_contentt" />
>
> > > <ImageView ------- etc etc/>
> > > </FrameLayout>
>
> > > In the PlayBackView class, you can define the onClick handlers or any
> > > other event handler as you want.
> > > Hope this will help you.
>
> > > On Nov 30, 7:59 am, MaheshSharma <[email protected]>
> > > wrote:
>
> > > > Hello All,
> > > > My app is kind of a music app and I have a playback bar that I need to
> > > > be visible across all the views.
>
> > > > I had three activities, A/B/C. Instead of adding the playback bar
> > > > explicitly to all A,B,C. I added the Playback Bar to A and made A,B,C
> > > > as ActivityGroups.
>
> > > > Since, A has the playback bar, now I when I start B from A, I call
> > > > setContentView from A to show B.
>
> > > > The problem is, once I call setContentView to show B, and then if the
> > > > user presses back key in B, then it goes to home screen, instead of
> > > > coming to A.
>
> > > > I have seen some snippets on web, which maintain the view stack and
> > > > when user presses the back key they pop up the previous view.
>
> > > > I couldnt implement that.
>
> > > > Questions :
> > > > 1) Is there any better way to having a activity like Playback bar/
> > > > Status bars across all the views/activities ?
>
> > > > 2) If the above way is the only way to do it,then how can I handle the
> > > > back key?
>
> > > > With Regards
> > > > MS.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en