Finding the ID of the current layout

by Snarky » Tue, 15 Mar 2011 05:04:57 GMT


Sponsored Links
 I'm sure this is far simpler than I'm making it out to be, but I'm
having trouble figuring out how to retrieve the ID of the current
view, so that I can conditionally alter the behavior of the "Back"
button.

Here's the scenario...I have four layouts that I'm using:
- Main
- Preferences
- Transaction List
- Transaction Details

Depending on the layout that's current, I want the Back button to
either take the user back to the Main layout (Prefs and T-List), or
back to the Transaction List (T-Details).

But, for the life of me, I can't figure out how to retrieve the
current layout's ID to use as fodder for the switch.

I'm far from a seasoned programmer, and this is a hobby project, but
it's been bugging me for a few days now, and I thought someone here
might have a suggestion.

Thanks!
Snarky

-- 



Re: Finding the ID of the current layout

by lbendlin » Tue, 15 Mar 2011 05:09:32 GMT


 here's how I identify image resources by name. You should be able to
do something similar for views. Just use "layout" rather than
"drawable"

cc.setImageResource(getContext().getResources().getIdentifier("image
name", "drawable", getContext().getPackageName()));




-- 


Sponsored Links


Re: Finding the ID of the current layout

by TreKing » Tue, 15 Mar 2011 05:11:39 GMT


 



Why not use two activities and let the system do it's thing (automatically
taking you back where you came from) instead of this conditional
tom-foolery?

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

-- 



Re: Finding the ID of the current layout

by Brill Pappin » Tue, 15 Mar 2011 06:32:13 GMT


 I had to do this recently.
There is apparently not an easy way to get the resource id of the layout 
your view was just created from, however I used the tag attribute to sort 
out which was which.

<... layout android:tag="view1">
 ..
</ ... layout>

in your view you can get getTag().

- Brill Pappin

-- 



Re: Finding the ID of the current layout

by Mark Murphy » Tue, 15 Mar 2011 06:35:13 GMT


 




Or, hang tight for a bit, and you can use fragments and the
FragmentManager, if some of these things might be on the screen at the
same time. The "hang tight" is just a matter of the community wrapping
its collective head around fragments and the new Android Compatibility
Library (with the painful acronym of ACL).

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android Training in Oslo:  http://bit.ly/fjBo24 

-- 



Other Threads

1. Milestone vs Nexus One was Google Nexus One unboxing and hands-on - Engadget Galleries

Procesor
Ram
Amoled

Tiga2nya itu unggul nexus

Pilih?
Ya nexus

Dari analisa nubi seperti saya, nexus lebih unggul.

Nah, miletone aja 7xxx,

Nexus yang lebih unggul tentunya..

X,xxx

JAPRI yudhis...@gmail.com
ym yudhistyaksyatria


-----Original Message-----
From: Jarring Bachroemsjah <jbachroems...@gmail.com>
Date: Sun, 3 Jan 2010 13:07:21 
To: <id-android@googlegroups.com>
Subject: Milestone vs Nexus One was Re: [id-android] Google Nexus One unboxing 
        and hands-on - Engadget Galleries

Perbedaan utamanya apa ya Bro, selain keyboard vs. virtual keyboard... Trus
kalo disuruh milih, kira2 mo pilih yg mana? :)







> Click 

2. Listening to a video stream and rendering it on the screen

Hello Devs....

Any ideas regarding inline ?



On Thu, Dec 31, 2009 at 12:19 PM, Android Development




-- 

3. Biloxi Android Group

4. Rooting milestone

5. Getting Published - Do I need a website - Market requirements? Publish as com.example? new namespace?

6. Getting Published - Do I need a website - Market requirements? Publish as com.example? new namespace?

7. Compatibility issue?