編輯:關於android開發
package com.example.Gallery; import com.example.Gallery.R; import android.os.Bundle; import android.app.Activity; import android.content.Context; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.ImageView; import android.widget.Toast; public class MainActivity extends Activity { /** Called when the activity is first created. */ private Gallery gallery; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); gallery = (Gallery)findViewById(R.id.gallery); //設置圖片適配器 gallery.setAdapter(new ImageAdapter(this)); //設置監聽器 gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) { Toast.makeText(MainActivity.this, "點擊了第"+(arg2+1)+"張圖片", Toast.LENGTH_LONG).show(); } }); } } class ImageAdapter extends BaseAdapter{ private Context context; //圖片源數組 private Integer[] imageInteger={ R.drawable.item1,R.drawable.item2,R.drawable.item3,R.drawable.item4, R.drawable.item5,R.drawable.item6,R.drawable.item7,R.drawable.item8, R.drawable.item9,R.drawable.item10,R.drawable.item11,R.drawable.item12, R.drawable.item13,R.drawable.item14,R.drawable.item15}; public ImageAdapter(Context c){ context = c; } @Override public int getCount() { return imageInteger.length; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return position; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(context); imageView.setImageResource(imageInteger[position]); imageView.setBackgroundColor(0xFF000000); imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); imageView.setLayoutParams(new Gallery.LayoutParams(136, 88)); return imageView; } }
效果執行圖:
Android高效計算——RenderScript(二),androidrenderscript3 RenderScript運行時層與反射層 3.1 RenderScri
Android Developer:Memory Monitor演示 這個演示展示了在Android Studio中Memory Monitor工具基本的用法和流程。M
側滑1,側滑如圖是效果圖
android Gui系統之WMS(2)----窗口的添加,androidwmsAndroid系統很多,但是最常用的就兩類,一類是有系統進場管理的,系統窗口。還有一類就是