You should use their recommended way.

That way you just call a findViewById, and if it returns null, you know 
it's the phone layout.

Plus it gets to be a headache when you need to have a landscape layout and 
multiple different sizes and resolutions!


On Tuesday, June 19, 2012 6:56:44 AM UTC+8, h4uw1n3 wrote:
>
> I'm really interested in android, i might be didn't have any skill in 
> java, but still i want to ask about this...
> according to 
> http://android-developers.blogspot.de/2011/07/new-tools-for-managing-screen-sizes.html
>
> Android will pick the resource that is closest to the device’s screen 
> size or orientation...for example this layout, which only shows the folder 
> list
>
>
> <https://lh6.googleusercontent.com/-2avCDWTrdBc/T9-sv0TTnXI/AAAAAAAABEw/Nup54Y16B7Y/s1600/unnamed.png>
>
> and the other one, which shows the folder list and the items on the 
> folder... 
>
>
> <https://lh6.googleusercontent.com/-ynOv3lsqGLM/T9-ssnDYVRI/AAAAAAAABEo/xqV9tcqPmY4/s1600/unnamed.jpg>
>
> this layout has more than 2 listactivity, which means the java coding also 
> different...
>
> so my question is, if we have to check in main activity, whether the 
> device is tablet or a phone, what's the point then using different 
> "res/layout" folder like "res/layout-small", "res/layout-large", 
> "res/layout-xlarge", we can just make the different file in the same folder 
> and using coding like this
>
> public class MyActivity extends Activity {
>     @Override protected void onCreate(Bundle savedInstanceState) {
>         super.onCreate();
>
>         Configuration config = getResources().getConfiguration();
>         if (config.smallestScreenWidthDp >= 600) {
>             setContentView(R.layout.main_activity_tablet);
>             */*hier coding for different layout for tablet*/*
>         } else {
>             setContentView(R.layout.main_activity);
>             */*here coding for phone's layout*/* }
>     }
>
> please correct me, if i misunderstanding about this... and also... sorry 
> about my english...
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to