2012-08-24 161 views
2

這些GridView是Android嗎?

我想用像google +或evernote這樣的界面製作應用程序,如何執行這些用戶界面?在Android中使用GridView?

+0

以下鏈接可以幫助你http://www.technotalkative.com/android-gridview-example/ –

回答

0

它們與此相似。但他們有他們自己的術語DashBoard

這裏是一個教程鏈接,

DashBoard..

這裏是說明幾件事情要你一個鏈接,

http://android-developers.blogspot.in/2010/05/twitter-for-android-closer-look-at.html

而且也是這個問題在這裏,這是以前討論它,

Android Dashboard Pattern

,這看起來是建議的方式做到這一點,

<com.google.android.apps.iosched.ui.widget.DashboardLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<Button android:id="@+id/home_btn_schedule" 
    style="@style/DashboardButton" 
    android:text="@string/btn_schedule" 
    android:drawableTop="@drawable/home_btn_schedule" /> 
<Button android:id="@+id/home_btn_map" 
    style="@style/DashboardButton" 
    android:text="@string/btn_map" 
    android:drawableTop="@drawable/home_btn_map" /> 
<Button android:id="@+id/home_btn_sessions" 
    style="@style/DashboardButton" 
    android:text="@string/btn_sessions" 
    android:drawableTop="@drawable/home_btn_sessions" /> 
<Button android:id="@+id/home_btn_starred" 
    style="@style/DashboardButton" 
    android:text="@string/btn_starred" 
    android:drawableTop="@drawable/home_btn_starred" /> 
<Button android:id="@+id/home_btn_vendors" 
    style="@style/DashboardButton" 
    android:text="@string/btn_vendors" 
    android:drawableTop="@drawable/home_btn_vendors" /> 
<Button android:id="@+id/home_btn_announcements" 
    style="@style/DashboardButton" 
    android:text="@string/btn_announcements" 
    android:drawableTop="@drawable/home_btn_announcements" /> 

Taken From Here..

0
public class Dashboard extends Activity 
    implements OnItemClickListener { 
Context con; 
static LauncherIcon[] ICONS = { 
     new LauncherIcon(R.drawable.breakfasdd, "text1"), 
     new LauncherIcon(R.drawable.lunch, "text2"), 
     new LauncherIcon(R.drawable.dinner1, "text3"), 
     new LauncherIcon(R.drawable.syn1, "text4"), 

}; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.dashboard); 
    GridView gridview = (GridView) findViewById(R.id.dashboard_grid); 
    gridview.setAdapter(new ImageAdapter(this)); 
    gridview.setOnItemClickListener(this); 
    } 

static class LauncherIcon { 
    final String text; 
    final int imgId; 

    public LauncherIcon(int imgId, String text) { 
     super(); 
     this.imgId = imgId; 
     this.text = text; 
    } 

} 

static class ImageAdapter extends BaseAdapter { 
    private Context mContext; 

    public ImageAdapter(Context c) { 
     mContext = c; 
    } 

    @Override 
    public int getCount() { 
     return ICONS.length; 
    } 

    @Override 
    public LauncherIcon getItem(int position) { 
     return null; 
    } 

    @Override 
    public long getItemId(int position) { 
     return 0; 
    } 

    static class ViewHolder { 
     public ImageView icon; 
     public TextView text; 
    } 

    @Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
     View v = convertView; 
     ViewHolder holder; 
     if (v == null) { 
      LayoutInflater vi = (LayoutInflater) mContext 
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

      v = vi.inflate(R.layout.dashboard_icon, null); 
      holder = new ViewHolder(); 
      holder.text = (TextView) v 
        .findViewById(R.id.dashboard_icon_text); 
      holder.icon = (ImageView) v 
        .findViewById(R.id.dashboard_icon_img); 
      v.setTag(holder); 
     } else { 
      holder = (ViewHolder) v.getTag(); 
     } 

     holder.icon.setImageResource(ICONS[position].imgId); 
     holder.text.setText(ICONS[position].text); 

     return v; 

    } 
} 

,並獲得項目選擇

@Override 
    public void onItemClick(AdapterView<?> parent, View v, int position, long id) { 
     int pos = position;{ 
} 

dashboard_icon.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@+id/dashboard_icon_img" 
     android:layout_width="fill_parent" 
     android:layout_height="96.0dip" 
     android:scaleType="fitCenter" /> 

    <TextView 
     android:id="@+id/dashboard_icon_text" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="20.0dip" 
     android:layout_marginTop="2.0dip" 
     android:gravity="center" 
     android:textAppearance="?android:textAppearanceSmall" 
     android:textColor="@android:color/black" /> 

</LinearLayout> 

dashboard.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 
    <Button 
     android:id="@+id/back" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical|center_horizontal" 
     android:layout_weight="1" 
     android:text="BACK" /> 

    <GridView 
     android:id="@+id/dashboard_grid" 
     style="@style/dashboard" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:listSelector="@android:color/transparent" 
     android:stretchMode="columnWidth" 
     android:verticalSpacing="20.0dip" /> 

</RelativeLayout>