【问题标题】:how to show different Numbers of columns in a single listview in portrait and landscape mode android?如何在纵向和横向模式android的单个列表视图中显示不同的列数?
【发布时间】:2012-05-01 22:54:17
【问题描述】:

谁能告诉我可以在列表视图中显示不同数量的列

例如:- 当我在纵向模式下看到列表视图时,它显示 3 列,当我在横向模式下看到列表视图时,它显示 4 列。我尝试这样做,但我的解决方案对我不起作用,我为布局文件夹中的 protrait 和 layout-land 文件夹中的横向定义了不同的布局,但它不适合我。

Can any one tell me is it possible to achive this . 

And one More thing it possible to execute some code by checking 

For Example:-  if(this is android phone){

                  execute this code;
                 }

                if(this is android tablet){

                        execute this code;
                     }

 like iphone and ipad developer do 

                   if(this is iphone )
                   {
                    execute this code ;
                      }



                   if(this is ipad )
                   {
                    execute this code ;
                      }

因为我在手机和平​​板电脑上都使用了相同的应用程序,并且有人想在手机和平​​板电脑上显示不同的东西。

Thanks in advance

【问题讨论】:

    标签: android listview


    【解决方案1】:

    试试下面的链接获取教程

    http://www.technotalkative.com/android-multi-column-listview/

    谢谢..!

    【讨论】:

    • 感谢您的回复,但我不想要这个,我想要具有不同列数的相同列表视图,例如当我使用我的应用程序时,纵向模式显示 3 列,横向显示 4 列。
    【解决方案2】:
     DisplayMetrics metrics = context.getResources().getDisplayMetrics();
     int width = metrics.widthPixels;
     int height = metrics.heightPixels;
    

    这给出了屏幕的尺寸,您可以根据这些值确定它是否是平板电脑。 See this link to know how to get dimensions of your device

    【讨论】:

      【解决方案3】:

      在 /res/layout 中创建更多同名布局

      选择根元素后,单击“下一步”,然后选择可用限定符(方向)之一并使用其属性定义 listView。

      【讨论】:

      • 我这样做似乎行不通。当我以纵向模式启动我的应用程序时,它会按预期显示,但是当我立即将其转为横向时,它不会按预期显示包含
      • 尽量
      • 和我之前遇到的问题一样
      猜你喜欢
      • 2014-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-13
      相关资源
      最近更新 更多