編輯:關於android開發
<GridLayout android:layout_width="match_parent" android:layout_height="match_parent" android:columnCount="1" > <HorizontalScrollView android:layout_width="match_parent" android:layout_height="88dp" android:layout_column="0" android:layout_gravity="left|bottom" android:layout_row="0" > <LinearLayout android:id="@+id/linearLayout_gridtableLayout" android:layout_width="1000dp" android:layout_height="79dp" android:orientation="horizontal" > <GridView android:id="@+id/gridview1" android:layout_width="600dp" android:layout_height="match_parent" android:background="#ffffff" android:columnWidth="100dp" android:gravity="center" android:horizontalSpacing="1dp" android:numColumns="6" android:scrollbarAlwaysDrawHorizontalTrack="true" android:scrollbarAlwaysDrawVerticalTrack="true" android:scrollbars="horizontal|vertical" android:verticalSpacing="1dp" /> </LinearLayout> </HorizontalScrollView> </GridLayout>
指定其中LinearLayout的寬度就能夠實現你GridView的長寬變化,如果它的長超過屏幕,則自動添加水平滾動條。
private int[] icon = { R.drawable.camera, R.drawable.wifi, R.drawable.temperature, R.drawable.lamp, R.drawable.wechat, R.drawable.mic, }; private String[] iconName = { "攝像頭", "網絡", "溫濕度", "電器", "微信", "語音" }; private GridView gview; private List<Map<String, Object>> data_list; private SimpleAdapter sim_adapter; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
//gridview數據適配器 gview = (GridView) findViewById(R.id.gridview1); //新建List data_list = new ArrayList<Map<String, Object>>(); //獲取數據 getData(); //新建適配器 String [] from ={"image","text"}; int [] to = {R.id.image,R.id.title}; sim_adapter = new SimpleAdapter(this, data_list, R.layout.items, from, to); //配置適配器 gview.setAdapter(sim_adapter); http://www.cnblogs.com/xiaobo-Linux/ qq463431476 } public List<Map<String, Object>> getData(){ //cion和iconName的長度是相同的,這裡任選其一都可以 for(int i=0;i<icon.length;i++){ Map<String, Object> map = new HashMap<String, Object>(); map.put("image", icon[i]); map.put("text", iconName[i]); data_list.add(map); } return data_list; }
Fragment裡:
oncreate裡邊初始化數據,oncreateview裡邊初始化gridview和綁定適配器public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View view = inflater.inflate(R.layout.gridview,container, false); gridview = (GridView) view.findViewById(R.id.gridview1); //新建List data_list = new ArrayList<Map<String, Object>>();
//http://www.cnblogs.com/xiaobo-Linux/ qq463431476 //獲取數據 getData(); //新建適配器 String [] from ={"image","text"}; int [] to = {R.id.image,R.id.title}; sim_adapter = new SimpleAdapter(getActivity(), data_list, R.layout.items, from, to); //配置適配器 gridview.setAdapter(sim_adapter); return view; }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } // http://www.cnblogs.com/xiaobo-Linux/ qq463431476 public List<Map<String, Object>> getData(){ //cion和iconName的長度是相同的,這裡任選其一都可以 for(int i=0;i<icon.length;i++){ Map<String, Object> map = new HashMap<String, Object>(); map.put("image", icon[i]); map.put("text", iconName[i]); data_list.add(map); } return data_list; }
ContentProvider域名替換小工具,contentprovider域名開發項目域名想怎麼換就怎麼換,就是這麼任性! 這是一個很有意思的小工具! 這是一個方便開發
Android面試題--事件處理,android試題--事件1、Handler 機制 Android 中主線程也叫 UI 線程,那麼從名字上我們也知道主線程主要是用來創建
Linux常用命令-50:crontab命令http://www.cnblogs.com/peida/archive/2013/01/08/2850483.html前一天
Linux內核系列—9.操作系統開發之Loader,linuxloader一個操作系統從開機到開始運行,大致經歷“引導—>加載內核入內存&m