編輯:關於android開發
<?xml version="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageSwitcher android:id="@+id/switcher" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" /> <Gallery android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="60dp" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:background="#ff00ff" android:gravity="center_vertical" android:spacing="16dp" /> </RelativeLayout>
package com.example.yanlei.mytk; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.Gallery.LayoutParams; import android.widget.ImageSwitcher; import android.widget.ImageView; import android.widget.ViewSwitcher; public class MainActivity extends AppCompatActivity implements ViewSwitcher.ViewFactory { private ImageSwitcher mSwitcher; private Gallery gallery; private Context mContext; private Integer[] mImageIds = { R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7, R.drawable.sample_8, R.drawable.sample_9, R.drawable.sample_10, R.drawable.sample_11}; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle("浏覽圖片"); mSwitcher = (ImageSwitcher) findViewById(R.id.switcher); gallery = (Gallery) findViewById(R.id.gallery); mSwitcher.setFactory(this); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out)); gallery.setAdapter(new ImageAdapter(this)); gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { mSwitcher.setImageResource(mImageIds[position]); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); } public class ImageAdapter extends BaseAdapter { public ImageAdapter(Context context) { mContext = context; } @Override public int getCount() { return mImageIds.length; } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); i.setImageResource(mImageIds[position]); i.setAdjustViewBounds(true); i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); i.setBackgroundResource(R.drawable.picture_frame); return i; } } @Override public View makeView() { ImageView i = new ImageView(this); i.setBackgroundColor(0xFF000000); i.setScaleType(ImageView.ScaleType.FIT_CENTER); i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); return i; } }
Android之ProgressBar初步應用,androidprogressbar這裡利用 ProgressBar 即時顯示下載進度。 途中碰到的問題: 1、主線程中不
今天我和同學們討論一下Android平台下如何調用系統方法發送短信、接收短信、系統的短信庫相關的問題。進入正題,我們先使用Eclipse工具模擬給自
Android用TabLayout實現類似網易選項卡動態滑動效果 此前我們用HorizontalScrollView也實現了類似網易選項卡動態滑動效果,詳見 Androi
Activity啟動模式之SingleTop,activitysingletop 當活動的啟動模式指定為singleTop,在啟動活動時如果發現返回棧的棧頂已經是該活動