当前位置: 首页>>代码示例>>Java>>正文


Java Gallery类代码示例

本文整理汇总了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));
}
 
开发者ID:yeriomin,项目名称:YalpStore,代码行数:20,代码来源:FullscreenImageActivity.java

示例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));
    }
}
 
开发者ID:yeriomin,项目名称:YalpStore,代码行数:18,代码来源:ImageAdapter.java

示例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();
}
 
开发者ID:Grasea,项目名称:Grandroid2,代码行数:21,代码来源:StateKeeper.java

示例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));
        }
    }
}
 
开发者ID:Grasea,项目名称:Grandroid2,代码行数:23,代码来源:StateKeeper.java

示例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));
}
 
开发者ID:liningwang,项目名称:camera,代码行数:22,代码来源:PictrueView.java

示例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;
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:17,代码来源:GalleryAdapter.java

示例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();
	}
}
 
开发者ID:roadlabs,项目名称:alternate-java-bridge-library,代码行数:22,代码来源:ImageGallery.java

示例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;
}
 
开发者ID:hubert1002,项目名称:WiCamera3D,代码行数:20,代码来源:CSGalleryAdapter.java

示例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));
}
 
开发者ID:LouiLam,项目名称:Android-Image-Cache-master,代码行数:19,代码来源:InteractiveDemo.java

示例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;
}
 
开发者ID:scarrozzo,项目名称:FacialExpressionRecognizer,代码行数:23,代码来源:Recognizer.java

示例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;
}
 
开发者ID:Sherchen,项目名称:ApiDemos,代码行数:22,代码来源:Gallery1.java

示例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);
}
 
开发者ID:Sherchen,项目名称:ApiDemos,代码行数:24,代码来源:Gallery2.java

示例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);
}
 
开发者ID:Sherchen,项目名称:ApiDemos,代码行数:19,代码来源:ImageSwitcher1.java

示例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;
}
 
开发者ID:slartus,项目名称:4pdaClient-plus,代码行数:20,代码来源:BbCodesBasePanel.java

示例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;
}
 
开发者ID:haikuowuya,项目名称:like_googleplus_layout,代码行数:18,代码来源:GalleryFlowActivity.java


注:本文中的android.widget.Gallery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。