當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。