本文整理汇总了Java中android.widget.Gallery类的典型用法代码示例。如果您正苦于以下问题:Java Gallery类的具体用法?Java Gallery怎么用?Java Gallery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Gallery类属于android.widget包,在下文中一共展示了Gallery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNewIntent
import android.widget.Gallery; //导入依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (null == DetailsActivity.app) {
Log.w(getClass().getSimpleName(), "No app stored");
finish();
return;
}
Gallery gallery = ((Gallery) findViewById(R.id.gallery));
gallery.setAdapter(new FullscreenImageAdapter(
this,
DetailsActivity.app.getScreenshotUrls(),
getWindowManager().getDefaultDisplay().getWidth(),
getWindowManager().getDefaultDisplay().getHeight()
));
gallery.setSelection(intent.getIntExtra(INTENT_SCREENSHOT_NUMBER, 0));
}
示例2: onPostExecute
import android.widget.Gallery; //导入依赖的package包/类
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
int w = screenWidth;
int h = screenWidth;
if (null != bitmap) {
w = Math.min(w, bitmap.getWidth());
h = Math.min(h, bitmap.getHeight());
}
imageView.setLayoutParams(new Gallery.LayoutParams(w, h));
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
if (imageView.getParent() instanceof Gallery) {
Gallery gallery = (Gallery) imageView.getParent();
gallery.setMinimumHeight(Math.max(gallery.getMeasuredHeight(), h));
}
}
示例3: save
import android.widget.Gallery; //导入依赖的package包/类
/**
* 儲存view的值,需設定過tag
*
* @param obj view物件
*/
protected void save(View obj) {
Editor editor = settings.edit();
if (obj instanceof TextView) {
editor.putString(obj.getTag().toString(), ((TextView) obj).getText().toString());
} else if (obj instanceof EditText) {
editor.putString(obj.getTag().toString(), ((EditText) obj).getText().toString()).commit();
} else if (obj instanceof ListView) {
editor.putInt(obj.getTag().toString(), ((ListView) obj).getFirstVisiblePosition()).commit();
} else if (obj instanceof Gallery) {
editor.putInt(obj.getTag().toString(), ((Gallery) obj).getFirstVisiblePosition()).commit();
} else if (obj instanceof GridView) {
editor.putInt(obj.getTag().toString(), ((GridView) obj).getFirstVisiblePosition()).commit();
}
editor.commit();
}
示例4: load
import android.widget.Gallery; //导入依赖的package包/类
/**
* 載入該view前次的值,需設定過tag
*
* @param obj view物件
* @return 回傳該載入的值,若沒有資料則為空字串(不是null)
*/
protected void load(View obj) {
String tag = obj.getTag().toString();
if (settings.contains(tag)) {
if (obj instanceof TextView) {
((TextView) obj).setText(settings.getString(tag, ""));
} else if (obj instanceof EditText) {
((EditText) obj).setText(settings.getString(tag, ""));
} else if (obj instanceof ListView) {
((ListView) obj).setSelectionFromTop(settings.getInt(tag, 0), 0);
} else if (obj instanceof Gallery) {
((Gallery) obj).setSelection(settings.getInt(tag, 0));
} else if (obj instanceof GridView) {
((GridView) obj).setSelection(settings.getInt(tag, 0));
}
}
}
示例5: onCreate
import android.widget.Gallery; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gallery = (Gallery) findViewById(R.id.gallery);
bitmap = SDUtil.getImagePathFromSD();
imageAdapter = new ImageAdapter(this, bitmap.size());
gallery.setAdapter(imageAdapter);
gallery.setOnItemSelectedListener(this);
gallery.setSelection(1);// 璁剧疆涓�鍔犺浇Activity灏辨樉绀虹殑鍥剧墖涓虹浜屽紶
gallery.setOnItemClickListener(this);
iv = (ImageView) findViewById(R.id.iv);
//imageSwitcher.setFactory(this);
// 璁剧疆鍔ㄧ敾鏁堟灉 娣″叆娣″嚭
//imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
//imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
}
示例6: getView
import android.widget.Gallery; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
/*产生ImageView对象*/
ImageView view = new ImageView(context);
/*设定图片给imageView对象*/
Bitmap bm = BitmapFactory.decodeFile(images.get(position));
view.setImageBitmap(bm);
/*重新设定图片的宽高*/
//view.setScaleType(ImageView.ScaleType.FIT_XY);
/*重新设定Layout的宽高*/
view.setLayoutParams(new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
return view;
}
示例7: BackgroundImage
import android.widget.Gallery; //导入依赖的package包/类
/**
*
* Sets an image to the background of the image gallery
*
* @param image The name of the image
*/
public void BackgroundImage(String image) {
String file;
if (image.contains(".")) {
file = image.split("\\.")[0];
} else {
file = image;
}
int img = container.$context().getResources().getIdentifier(file, "drawable", container.$form().getPackageName());
if (resourceId!=-1) {
((Gallery) container.$form().findViewById(resourceId)).setBackgroundDrawable(container.$context().getResources().getDrawable(img));
} else {
view.setBackgroundDrawable(container.$context().getResources().getDrawable(img));
view.requestLayout();
}
}
示例8: CSGalleryAdapter
import android.widget.Gallery; //导入依赖的package包/类
public CSGalleryAdapter(Context context) {
mContext = context;
mDimension = false;
mViewList = new ArrayList<View>();
mOrgViewSizeList = new HashMap<Integer,Size>();
//预设控件自适应所使用的显示参数
initDisplay();
//初始化一个默认元素
TextView nonItem = new TextView(mContext);
nonItem.setText("还没有添加元素...");
nonItem.setTextSize(22);
nonItem.setGravity(Gravity.CENTER);
nonItem.setTextColor(Color.parseColor("#ff0000"));
nonItem.setBackgroundResource(android.R.drawable.toast_frame);
nonItem.setLayoutParams(new Gallery.LayoutParams(200, 200));
mNonItem = nonItem;
}
示例9: onCreate
import android.widget.Gallery; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Gallery gallery = (Gallery) findViewById(R.id.gallery);
mCache = ImageCache.getInstance(this);
mCache.setCacheMaxSize(1 * 1024 /* mega */* 1024 /* kilo */);
initData();
setListAdapter(TestData.generateAdapter(this, mTestData, R.layout.thumbnail_item, mCache,
320, 200));
gallery.setAdapter(TestData.generateAdapter(this, mTestData, R.layout.small_thumbnail_item,
mCache, 160, 100));
}
示例10: Recognizer
import android.widget.Gallery; //导入依赖的package包/类
public Recognizer(final Activity parent, org.altervista.scarrozzo.facialexpressionrecognizer.util.FaceAdapter imgAdapt,
Gallery faceGallery, ImageView faceView, String filePath,
String[] progStr, Uri mCapturedImageURI) {
this.parent = parent;
this.imgAdapt = imgAdapt;
this.faceGallery = faceGallery;
this.faceView = faceView;
this.filePath = filePath;
this.progStr = progStr;
this.ioError = null;
this.mCapturedImageURI = mCapturedImageURI;
this.expressions = new String[]{ parent.getResources().getString(R.string.exp_neutral),
parent.getResources().getString(R.string.exp_happy),
parent.getResources().getString(R.string.exp_surprise),
parent.getResources().getString(R.string.exp_anger),
parent.getResources().getString(R.string.exp_fear),
parent.getResources().getString(R.string.exp_sad),
parent.getResources().getString(R.string.exp_disgust)
};
this.deleteFlag = false;
}
示例11: getView
import android.widget.Gallery; //导入依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
convertView = new ImageView(mContext);
imageView = (ImageView) convertView;
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setLayoutParams(new Gallery.LayoutParams(
(int) (ITEM_WIDTH * mDensity + 0.5f),
(int) (ITEM_HEIGHT * mDensity + 0.5f)));
// The preferred Gallery item background
imageView.setBackgroundResource(mGalleryItemBackground);
} else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(mImageIds[position]);
return imageView;
}
示例12: onCreate
import android.widget.Gallery; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gallery_2);
// Get a cursor with all people
Cursor c = getContentResolver().query(Contacts.CONTENT_URI,
CONTACT_PROJECTION, null, null, null);
startManagingCursor(c);
SpinnerAdapter adapter = new SimpleCursorAdapter(this,
// Use a template that displays a text view
android.R.layout.simple_gallery_item,
// Give the cursor to the list adatper
c,
// Map the NAME column in the people database to...
new String[] {Contacts.DISPLAY_NAME},
// The "text1" view defined in the XML template
new int[] { android.R.id.text1 });
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setAdapter(adapter);
}
示例13: onCreate
import android.widget.Gallery; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.image_switcher_1);
mSwitcher = (ImageSwitcher) findViewById(R.id.switcher);
mSwitcher.setFactory(this);
mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_in));
mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_out));
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setAdapter(new ImageAdapter(this));
g.setOnItemSelectedListener(this);
}
示例14: getView
import android.widget.Gallery; //导入依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
// Get a View to display image data
convertView = new ImageView(this.myContext);
((ImageView) convertView).setScaleType(ImageView.ScaleType.FIT_END);
// Set the Width & Height of the individual images
convertView.setLayoutParams(new Gallery.LayoutParams((int) (m_Density * 30), (int) (m_Density * 30)));
}
try {
((ImageView) convertView).setImageBitmap(m_GetBitmapFunc.getBitmap(mContext, m_Images[position].FilePath));
convertView.setTag(m_Images[position]);
} catch (IOException e) {
e.printStackTrace();
}
return convertView;
}
示例15: getView
import android.widget.Gallery; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if (null == convertView)
{
convertView = new MyImageView(GalleryFlowActivity.this);
int width = (int) (80* getResources().getDisplayMetrics().density);
int height = (int) (120* getResources().getDisplayMetrics().density);
convertView.setLayoutParams(new Gallery.LayoutParams(width, height));
}
ImageView imageView = (ImageView) convertView;
imageView.setImageDrawable(mBitmaps.get(position%mBitmaps.size()));
imageView.setScaleType(ScaleType.FIT_XY);
return imageView;
}