Java Code Examples for android.widget.Gallery

The following are top voted examples for showing how to use android.widget.Gallery. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: YalpStore   File: FullscreenImageActivity.java   View source code 6 votes vote down vote up
@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));
}
 
Example 2
Project: YalpStore   File: ImageAdapter.java   View source code 6 votes vote down vote up
@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));
    }
}
 
Example 3
Project: Grandroid2   File: StateKeeper.java   View source code 6 votes vote down vote up
/**
 * 儲存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();
}
 
Example 4
Project: Grandroid2   File: StateKeeper.java   View source code 6 votes vote down vote up
/**
 * 載入該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));
        }
    }
}
 
Example 5
Project: camera   File: PictrueView.java   View source code 6 votes vote down vote up
@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));
}
 
Example 6
Project: mobile-manager-tool   File: GalleryAdapter.java   View source code 6 votes vote down vote up
@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;
}
 
Example 7
Project: alternate-java-bridge-library   File: ImageGallery.java   View source code 6 votes vote down vote up
/**
 * 
 * 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();
	}
}
 
Example 8
Project: WiCamera3D   File: CSGalleryAdapter.java   View source code 6 votes vote down vote up
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;
}
 
Example 9
Project: Android-Image-Cache-master   File: InteractiveDemo.java   View source code 6 votes vote down vote up
@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));
}
 
Example 10
Project: FacialExpressionRecognizer   File: Recognizer.java   View source code 6 votes vote down vote up
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;
}
 
Example 11
Project: ApiDemos   File: Gallery1.java   View source code 6 votes vote down vote up
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;
}
 
Example 12
Project: ApiDemos   File: Gallery2.java   View source code 6 votes vote down vote up
@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);
}
 
Example 13
Project: ApiDemos   File: ImageSwitcher1.java   View source code 6 votes vote down vote up
@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);
}
 
Example 14
Project: 4pdaClient-plus   File: BbCodesBasePanel.java   View source code 6 votes vote down vote up
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;
}
 
Example 15
Project: like_googleplus_layout   File: GalleryFlowActivity.java   View source code 6 votes vote down vote up
@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;
}
 
Example 16
Project: itmarry   File: ImageAdapter.java   View source code 6 votes vote down vote up
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
	// TODO Auto-generated method stub
	ImageView img = (ImageView)arg1;
	if(img == null) {
		img = new ImageView(mContext);
	}
	if( pic_string_id != null )
	{
		img.setImageDrawable(LoadImageMgr.getInstance().loadDrawble(pic_string_id.get(arg0), img, LoadImageMgr.getInstance().imageCallBack));
	}else
	{
		img.setImageDrawable(pic_array_id.get(arg0));
	}
	img.setLayoutParams(new Gallery.LayoutParams((int)mContext.getResources().getDimension(R.dimen.galley_high),
									(int)mContext.getResources().getDimension(R.dimen.galley_high)));
	return img;
}
 
Example 17
Project: ChangYou   File: NewsActivity.java   View source code 6 votes vote down vote up
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) 
{
	/*
	 * 动态生成每个下拉项对应的View,每个下拉项View由LinearLayout
	 *中包含一个ImageView及一个TextView构成
	*/
	//初始化LinearLayout
	ll=new LinearLayout(context_Activity);
	ll.setOrientation(LinearLayout.HORIZONTAL);		//设置朝向		
	//初始化ImageView
	i_love=new ImageView(context_Activity);
	i_love.setImageDrawable(context_Activity.getResources().getDrawable(msgIds.get(arg0)));//设置图片
	i_love.setScaleType(ImageView.ScaleType.FIT_XY);
	i_love.setLayoutParams(new Gallery.LayoutParams(dm.widthPixels,dm.widthPixels*80/320));
	ll.addView(i_love);//添加到LinearLayout中
	return ll;
}
 
Example 18
Project: EmopAndroid   File: HotActivity.java   View source code 6 votes vote down vote up
@Override
public View getView(int index, View oldView, ViewGroup arg2) {
	// TODO Auto-generated method stub
	LinearLayout liner = new LinearLayout(HotActivity.this);
	liner.setBackgroundColor(getResources().getColor(R.color.color_hot_item));
	liner.setLayoutParams(new Gallery.LayoutParams(Gallery.LayoutParams.FILL_PARENT,
			Gallery.LayoutParams.FILL_PARENT
			));
	
	ImageView i = new ImageView (HotActivity.this); 
	i.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
			LinearLayout.LayoutParams.FILL_PARENT
			));			
	i.setScaleType(ScaleType.CENTER_CROP);
	
	liner.addView(i);
	HashMap<String, Object> item = (HashMap<String, Object>)this.getItem(index);
	String url = (String)item.get("ItemImage");			
	client.appImgLoader.loadImage(url, i, winWidth, true);
	//client.appImgLoader.loadImage(url, i);
	
	return liner;  
}
 
Example 19
Project: mockey   File: PickBackgroundImagesActivity.java   View source code 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	// create the view
	ImageView imageView = new ImageView(galleryContext);
	// specify the bitmap at this position in the array
	imageView.setImageBitmap(MyApplication.getInstance()
			.getBackgroundBitmap(position));
	// set layout options
	imageView.setLayoutParams(new Gallery.LayoutParams(300, 200));
	// scale type within view area
	imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
	// set default gallery item background
	imageView.setBackgroundResource(defaultItemBackground);
	// return the view
	return imageView;
}
 
Example 20
Project: JDMall   File: IndexActivity.java   View source code 6 votes vote down vote up
@Override
protected void findViewById() {
	// TODO Auto-generated method stub
	mIndexHour = (TextView) findViewById(R.id.index_miaosha_hour);
	mIndexMin = (TextView) findViewById(R.id.index_miaosha_min);
	mIndexSeconds = (TextView) findViewById(R.id.index_miaosha_seconds);
	mIndexPrice = (TextView) findViewById(R.id.index_miaosha_price);
	mIndexRawPrice = (TextView) findViewById(R.id.index_miaosha_raw_price);

	mMiaoShaImage = (ImageView) findViewById(R.id.index_miaosha_image);
	mViewPager = (JazzyViewPager) findViewById(R.id.index_product_images_container);
	mIndicator = (LinearLayout) findViewById(R.id.index_product_images_indicator);

	mStormGallery = (Gallery) findViewById(R.id.index_jingqiu_gallery);
	mPromotionGallery = (Gallery) findViewById(R.id.index_tehui_gallery);

	mSearchBox = (EditText) findViewById(R.id.index_search_edit);
	mSearchButton = (ImageButton) findViewById(R.id.index_search_button);
	mTopLayout = (LinearLayout) findViewById(R.id.index_top_layout);
}
 
Example 21
Project: arduino2android   File: HelpActivity.java   View source code 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

	//create the view
	ImageView imageView = new ImageView(galleryContext);
	//specify the bitmap at this position in the array
	imageView.setImageBitmap(imageBitmaps[position]);
	//set layout options
	imageView.setLayoutParams(new Gallery.LayoutParams(300, 200));
	//scale type within view area
	imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
	//set default gallery item background
	imageView.setBackgroundResource(defaultItemBackground);
	//return the view
	return imageView;
}
 
Example 22
Project: Field-Book   File: GalleryImageAdapter.java   View source code 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder;
    if (convertView == null) {
        holder = new ViewHolder();
        imageView = new ImageView(this.context);
        imageView.setPadding(3, 3, 3, 3);
        convertView = imageView;
        holder.imageView = imageView;
        convertView.setTag(holder);

    } else {

        holder = (ViewHolder) convertView.getTag();
    }

    holder.imageView.setImageDrawable(plotsImages.get(position));
    holder.imageView.setScaleType(ScaleType.FIT_CENTER);
    holder.imageView.setLayoutParams(new Gallery.LayoutParams(270, 450));

    return imageView;
}
 
Example 23
Project: CMPUT301F13T08   File: PicAdapter.java   View source code 6 votes vote down vote up
/**
    * get view specifies layout and display options for each thumbnail in the
    * gallery
    * 
    * @param position
    *            the index of the selected photo in the adapter
    * @param convertView
    *            the view that is going to be converted to user's desire
    * @param parent
    *            a ViewGroup object
    * @return the converted view for the Photo
    */
   public View getView(int position, View convertView, ViewGroup parent) {

/* create the view */
ImageView imageView = new ImageView(galleryContext);

/* specify the bitmap at this position in the array */
imageView.setImageBitmap(imageBitmaps[position]);

/* set layout options */
imageView.setLayoutParams(new Gallery.LayoutParams(300, 200));

/* scale type within view area */
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);

/* set default gallery item background */
imageView.setBackgroundResource(defaultItemBackground);

/* return the view */
return imageView;
   }
 
Example 24
Project: ZalartAndroid   File: AddReportView.java   View source code 6 votes vote down vote up
public AddReportView(Activity activity) {
	super(activity);

	mBtnPicture = (Button) activity.findViewById(R.id.btnPicture);
	mBtnAddCategory = (Button) activity.findViewById(R.id.add_category);
	mPickDate = (Button) activity.findViewById(R.id.pick_date);
	mPickTime = (Button) activity.findViewById(R.id.pick_time);
	mDeleteReport = (Button) activity.findViewById(R.id.delete_report);
	mLatitude = (EditText) activity.findViewById(R.id.incident_latitude);
	mLongitude = (EditText) activity.findViewById(R.id.incident_longitude);
	gallery = (Gallery) activity.findViewById(R.id.gallery);
	mIncidentTitle = (EditText) activity.findViewById(R.id.incident_title);
	mIncidentLocation = (EditText) activity
			.findViewById(R.id.incident_location);
	mIncidentDesc = (EditText) activity.findViewById(R.id.incident_desc);
	mNews = (EditText) activity.findViewById(R.id.report_news);
	mSwitcher = (ImageSwitcher) activity
			.findViewById(R.id.sel_image_switcher);
	mSwitcher.setInAnimation(AnimationUtils.loadAnimation(activity,
			android.R.anim.fade_in));
	mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(activity,
			android.R.anim.fade_out));
	
}
 
Example 25
Project: MEng   File: Gallery1.java   View source code 6 votes vote down vote up
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;
}
 
Example 26
Project: MEng   File: Gallery2.java   View source code 6 votes vote down vote up
@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);
}
 
Example 27
Project: MEng   File: ImageSwitcher1.java   View source code 6 votes vote down vote up
@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);
}
 
Example 28
Project: Fishification   File: FeedFishFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    m_view = inflater.inflate(R.layout.fragment_fish_feed, container, false);
    m_defaultBackground = m_view.getBackground();

    // Init Gallery
    Gallery gallery = (Gallery) m_view.findViewById(R.id.fishBoxGallery);
    gallery.setAdapter(new FishFoodBoxAdapter(m_view.getContext()));

    // Init Sensor
    Context context = m_view.getContext();
    m_sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    m_lastUpdate = System.currentTimeMillis();

    return m_view;
}
 
Example 29
Project: codeexamples-android   File: Gallery1.java   View source code 6 votes vote down vote up
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;
}
 
Example 30
Project: codeexamples-android   File: Gallery2.java   View source code 6 votes vote down vote up
@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);
}
 
Example 31
Project: codeexamples-android   File: ImageSwitcher1.java   View source code 6 votes vote down vote up
@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);
}
 
Example 32
Project: deview-2013-samples   File: Gallery1.java   View source code 6 votes vote down vote up
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;
}
 
Example 33
Project: deview-2013-samples   File: Gallery2.java   View source code 6 votes vote down vote up
@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);
}
 
Example 34
Project: deview-2013-samples   File: ImageSwitcher1.java   View source code 6 votes vote down vote up
@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);
}
 
Example 35
Project: gundog-engine   File: UpgradeRightLayout.java   View source code 6 votes vote down vote up
public void reset() {
	upgradeLayout = new LinearLayout(activity);
	upgradeLayout.setOrientation(LinearLayout.VERTICAL);

	ADS.placeObtrusiveADMobAD(upgradeLayout);
	selectionLayout = new LinearLayout(activity);
	selectionLayout.setOrientation(LinearLayout.VERTICAL);

	Gallery gallery = generateRaceSelectionLayout();
	upgradeLayout.addView(gallery);
	ImageView seperator = new ImageView(activity);
	seperator.setImageBitmap(BitmapCache.getBitmap(R.drawable.menu_seperator));
	upgradeLayout.addView(seperator);

	upgradeLayout.addView(selectionLayout);

}
 
Example 36
Project: Joszolgalat_Android_App   File: AddReportView.java   View source code 6 votes vote down vote up
public AddReportView(Activity activity) {
	super(activity);

	mBtnPicture = (Button) activity.findViewById(R.id.btnPicture);
	mBtnAddCategory = (Button) activity.findViewById(R.id.add_category);
	mPickDate = (Button) activity.findViewById(R.id.pick_date);
	mPickTime = (Button) activity.findViewById(R.id.pick_time);
	mDeleteReport = (Button) activity.findViewById(R.id.delete_report);
	mLatitude = (EditText) activity.findViewById(R.id.incident_latitude);
	mLongitude = (EditText) activity.findViewById(R.id.incident_longitude);
	gallery = (Gallery) activity.findViewById(R.id.gallery);
	mIncidentTitle = (EditText) activity.findViewById(R.id.incident_title);
	mIncidentLocation = (EditText) activity
			.findViewById(R.id.incident_location);
	mIncidentDesc = (EditText) activity.findViewById(R.id.incident_desc);
	mNews = (EditText) activity.findViewById(R.id.report_news);
	mSwitcher = (ImageSwitcher) activity
			.findViewById(R.id.sel_image_switcher);
	mSwitcher.setInAnimation(AnimationUtils.loadAnimation(activity,
			android.R.anim.fade_in));
	mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(activity,
			android.R.anim.fade_out));
	this.mapView = (MapView) activity.findViewById(R.id.location_map);
}
 
Example 37
Project: buildAPKsSamples   File: Wallpaper.java   View source code 5 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.wallpaper);

    mGallery = (Gallery) findViewById(R.id.gallery);
    mGallery.setAdapter(new ImageAdapter(this));
    mGallery.setOnItemSelectedListener(this);
    mGallery.setOnItemClickListener(this);
}
 
Example 38
Project: buildAPKsSamples   File: Wallpaper.java   View source code 5 votes vote down vote up
public View getView(final int position, View convertView, ViewGroup parent) {
    ImageView i = new ImageView(mContext);

    i.setImageResource(THUMB_IDS[position]);
    i.setAdjustViewBounds(true);
    i.setLayoutParams(new Gallery.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    i.setBackgroundResource(android.R.drawable.picture_frame);
    return i;
}
 
Example 39
Project: FaceAI_Android   File: FaceActivity.java   View source code 5 votes vote down vote up
private void initViews() {
	mPhoto = (ImageView) findViewById(R.id.id_photo);
	mGetImage = (ImageButton) findViewById(R.id.id_getImage);
	mDetect = (TextView) findViewById(R.id.id_detect);
	// mTip = (TextView) findViewById(R.id.id_tip);
	mWaitting = findViewById(R.id.id_waiting);

	gallery = (Gallery) findViewById(R.id.id_gallery);
	imageSwitcher = (ImageSwitcher) findViewById(R.id.id_imageSwitcher);
	scrollView = (ScrollView) findViewById(R.id.scrollView1);
	scrollView.setVerticalScrollBarEnabled(false);

}
 
Example 40
Project: FaceAI_Android   File: MyImageAdapter.java   View source code 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

	ImageView imageView = new ImageView(context);
	imageView.setBackgroundResource(image[position % 13]);
	imageView.setLayoutParams(new Gallery.LayoutParams(400, 300));
	imageView.setScaleType(ScaleType.FIT_XY);

	return imageView;
}