文件名称:gallery简单实现 图片调整
文件大小:2KB
文件格式:JAVA
更新时间:2017-09-25 12:13:46
gallery
package e gallery; import android app Activity; import android os Bundle; import android view LayoutInflater; import android view View; import android view ViewGroup; import android view ViewGroup MarginLayoutParams; import android widget AdapterView; import android widget AdapterView OnItemSelectedListener; import android widget BaseAdapter; import android widget Gallery; import android widget ImageView; import e gallery R; public class MainActivity extends Activity implements OnItemSelectedListener { Gallery gallery; ImageView main imageView; ImageView picture imageView; Gesture+ gesture; int[] ids1 { R drawable b R drawable c R drawable d R drawable f R drawable g }; @Override protected void onCreate Bundle savedInstanceState { super onCreate savedInstanceState ; setContentView R layout main ; main imageView ImageView findViewById R id main imageView ; gallery Gallery findViewById R id gallery ; gallery setOnItemSelectedListener this ; 怎么设置从中间开始 gallery setAdapter new MyAdapter ; } class MyAdapter extends BaseAdapter{ @Override public int getCount { return Integer MAX VALUE; } @Override public Object getItem int position { return null; } @Override public long getItemId int position { return 0; } @Override public View getView int position View convertView ViewGroup parent { LayoutInflater layoutInflater LayoutInflater from MainActivity this ; convertView layoutInflater inflate R layout picture null ; picture imageView ImageView convertView findViewById R id picture imageView ; picture imageView setImageResource ids1[position % 5] ; return convertView; } } @Override public void onItemSelected AdapterView< > parent View view int position long id { main imageView setImageResource ids1[position % 5] ; } @Override public void onNothingSelected AdapterView< > parent { } }">package e gallery; import android app Activity; import android os Bundle; import android view LayoutInflater; import android view View; import android view ViewGroup; import android view ViewGroup MarginLayoutParams; import android widget AdapterView; import android widget AdapterView OnItemSelecte [更多]