免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

GridView的使用-創(chuàng)新互聯(lián)

創(chuàng)新互聯(lián)基于分布式IDC數(shù)據(jù)中心構(gòu)建的平臺為眾多戶提供西部信息機(jī)房 四川大帶寬租用 成都機(jī)柜租用 成都服務(wù)器租用。>public class MainActivity extends Activity { private GridView gridView; private int[] images = {R.drawable.img_item0,R.drawable.img_item1 ,R.drawable.img_item2,R.drawable.img_item3,R.drawable.img_item4, R.drawable.img_item5,R.drawable.img_item6,R.drawable.img_item7, R.drawable.img_item8}; private String[] desc = {"該減肥了","該運(yùn)動運(yùn)動了","","","","","","",""}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gridview); gridView= (GridView) findViewById(R.id.gv); MyAdapter adapter= new MyAdapter(images,desc); gridView.setAdapter(adapter); gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Animation anim= new TranslateAnimation(-2, 2, 0, 0,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f); anim.setDuration(1000); anim.setRepeatCount(3); anim.setRepeatMode(Animation.REVERSE); ImageView image= (ImageView) view.findViewById(R.id.image); image.setAnimation(anim); anim.start(); } }); } class MyAdapter extends BaseAdapter{ int[] imgItemRes; String[] imgItemDesc; public MyAdapter(int[] imgItemRes,String[] imgItemDesc){ this.imgItemRes = imgItemRes; this.imgItemDesc = imgItemDesc; } @Override public int getCount() { return imgItemRes.length; } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView==null){ LayoutInflater inflater= getLayoutInflater(); convertView= inflater.inflate(R.layout.gridviewitem, null); } ImageView image= (ImageView) convertView.findViewById(R.id.image); TextView text= (TextView) convertView.findViewById(R.id.text); image.setImageResource(imgItemRes[position]); text.setText(imgItemDesc[position]); return convertView; } } } gridview.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >  <TextView
android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />  <GridView 
android:id="@+id/gv"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:columnWidth="60dp"
        android:numColumns="3"
        android:verticalSpacing="10dp"
        android:horizontalSpacing="15dp"
        android:stretchMode="columnWidth"
        android:gravity="center"   /></LinearLayout>

gridviewitem.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:gravity="center_horizontal"   >  <ImageView
android:id="@+id/image"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"   />  <TextView
android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"   /></LinearLayout>
GridView的使用

分享標(biāo)題:GridView的使用-創(chuàng)新互聯(lián)
瀏覽地址:http://m.newbst.com/article36/dpshsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)靜態(tài)網(wǎng)站網(wǎng)站排名關(guān)鍵詞優(yōu)化手機(jī)網(wǎng)站建設(shè)微信小程序

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管