Java Code Examples for android.widget.Gallery

The following examples show how to use android.widget.Gallery. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: DevUtils   Source File: GPUFilterACVAdapter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 创建 TextView
 * @param position 对应索引
 * @return {@link BaseTextView}
 */
private BaseTextView createTextView(int position) {
    ACVFileBean acvFileBean = getItem(position);

    boolean isSelect = (selectPosition == position);
    int width = SizeUtils.dipConvertPx(100f);
    Gallery.LayoutParams layoutParams = new Gallery.LayoutParams(width, Gallery.LayoutParams.MATCH_PARENT);
    // 初始化 View
    BaseTextView baseTextView = new BaseTextView(context);
    ViewHelper.get().setText(baseTextView, acvFileBean.acvName)
            .setBold(baseTextView, isSelect)
            .setTextGravity(baseTextView, Gravity.CENTER)
            .setTextColor(baseTextView, ResourceUtils.getColor(isSelect ? R.color.red : R.color.black))
            .setTextSizeBySp(baseTextView, isSelect ? 18.0f : 13.0f)
            .setLayoutParams(baseTextView, layoutParams);

    return baseTextView;
}
 
Example 2
Source Project: DevUtils   Source File: GPUFilterAdapter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 创建 TextView
 * @param position 对应索引
 * @return {@link BaseTextView}
 */
private BaseTextView createTextView(int position) {
    FilterItem filterItem = getItem(position);

    boolean isSelect = (selectPosition == position);
    int width = SizeUtils.dipConvertPx(100f);
    Gallery.LayoutParams layoutParams = new Gallery.LayoutParams(width, Gallery.LayoutParams.MATCH_PARENT);
    // 初始化 View
    BaseTextView baseTextView = new BaseTextView(context);
    ViewHelper.get().setText(baseTextView, filterItem.filterName)
            .setBold(baseTextView, isSelect)
            .setTextGravity(baseTextView, Gravity.CENTER)
            .setTextColor(baseTextView, ResourceUtils.getColor(isSelect ? R.color.red : R.color.black))
            .setTextSizeBySp(baseTextView, isSelect ? 18.0f : 13.0f)
            .setLayoutParams(baseTextView, layoutParams);

    return baseTextView;
}
 
Example 3
@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 4
Source Project: YalpStore   Source File: ImageAdapter.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onPostExecute(Void aVoid) {
    super.onPostExecute(aVoid);
    int w = screenWidth;
    int h = screenWidth;
    Drawable drawable = imageView.getDrawable();
    if (drawable instanceof BitmapDrawable) {
        Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
        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 5
Source Project: mobile-manager-tool   Source File: GalleryAdapter.java    License: MIT License 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 6
@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 7
Source Project: codeexamples-android   Source File: Gallery2.java    License: Eclipse Public License 1.0 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 8
@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 9
Source Project: ShoppingCartActivity   Source File: BannerViewPager.java    License: Apache License 2.0 5 votes vote down vote up
private void init() {
	listImgs = new ArrayList<ImageView>(); // 图片组
	int len = mUrllist.size() != 0 ? mUrllist.size() : mAdsId.size();
	for (int i = 0; i < len; i++) {
		ImageView imageview = new ImageView(mContext); // 实例化ImageView的对象
		imageview.setScaleType(ImageView.ScaleType.FIT_XY); // 设置缩放方式
		imageview.setLayoutParams(new Gallery.LayoutParams(
				Gallery.LayoutParams.MATCH_PARENT,
				Gallery.LayoutParams.MATCH_PARENT));
		if (mUrllist.size() == 0) {// 本地加载图片
			imageview.setImageResource(Integer.valueOf(mAdsId.get(i).url)); // 为ImageView设置要显示的图片
			imageview.setScaleType(ImageView.ScaleType.CENTER_CROP);
		} else { // 网络加载图片
			// ImageLoader.getInstance().displayImage(mUrllist.get(i).getImageUrl(),
			// imageview, ImageLoaderUtils.getOptions());
			imageview.setScaleType(ImageView.ScaleType.CENTER_CROP);
		}
		final int imagePosition = i;
		imageview.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (onItemClickListener != null)
					onItemClickListener.onItemClick(imagePosition);
			}
		});
		listImgs.add(imageview);
	}
}
 
Example 10
Source Project: Android-HowOld   Source File: FaceActivity.java    License: MIT License 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 11
Source Project: Android-HowOld   Source File: MyImageAdapter.java    License: MIT License 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;
}
 
Example 12
Source Project: 4pdaClient-plus   Source File: BbCodesBasePanel.java    License: Apache License 2.0 5 votes vote down vote up
public BbCodesBasePanel(Context context, Gallery gallery, EditText editText,
                        IGetBitmap getBitmap) {
    mContext = context;
    m_GetBitmapFunc = getBitmap;
    initVars();
    gallery.setAdapter(new ImageAdapter(context, getImages()));
    txtPost = editText;

    gallery.setSelection(3, true);
}
 
Example 13
Source Project: 4pdaClient-plus   Source File: BbCodesPanel.java    License: Apache License 2.0 5 votes vote down vote up
public BbCodesPanel(Context context, Gallery gallery, EditText editText) {
    super(context, gallery, editText);


    gallery.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            try {
                String bbCode = m_BbCodes[i];
                if (bbCode.equals("LIST")) {
                    getListBbCodeOnClickListener("");
                } else if (bbCode.equals("NUMLIST")) {
                    getListBbCodeOnClickListener("=1");
                } else if (bbCode.equals("URL")) {
                    getUrlBbCodeOnClickListener();
                } else if (bbCode.equals("SPOILER")) {
                    getSpoilerBbCodeOnClickListener(i);
                } else if (bbCode.equals("COLOR") || bbCode.equals("BACKGROUND")) {
                    getColorBbCodeOnClickListener(bbCode, i);
                } else if (bbCode.equals("SIZE")) {
                    getSizeBbCodeOnClickListener(i);
                } else {

                    bbCodeClick(i);

                }
            } catch (Exception ex) {
                AppLog.e(mContext, ex);
            }
        }
    });


}
 
Example 14
Source Project: UltimateAndroid   Source File: ImageFilterActivity.java    License: Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	Bitmap bmImg = BitmapFactory
			.decodeResource(mContext.getResources(),
					filterArray.get(position).filterID);
	int width = 100;// bmImg.getWidth();
	int height = 100;// bmImg.getHeight();
	bmImg.recycle();
	ImageView imageview = new ImageView(mContext);
	imageview.setImageResource(filterArray.get(position).filterID);
	imageview.setLayoutParams(new Gallery.LayoutParams(width, height));
	imageview.setScaleType(ImageView.ScaleType.FIT_CENTER);// ������ʾ��������
	return imageview;
}
 
Example 15
Source Project: UltimateAndroid   Source File: ImageFilterActivity.java    License: Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	Bitmap bmImg = BitmapFactory
			.decodeResource(mContext.getResources(),
					filterArray.get(position).filterID);
	int width = 100;// bmImg.getWidth();
	int height = 100;// bmImg.getHeight();
	bmImg.recycle();
	ImageView imageview = new ImageView(mContext);
	imageview.setImageResource(filterArray.get(position).filterID);
	imageview.setLayoutParams(new Gallery.LayoutParams(width, height));
	imageview.setScaleType(ImageView.ScaleType.FIT_CENTER);// ������ʾ��������
	return imageview;
}
 
Example 16
public View getView(int position, View convertView, ViewGroup parent) {
    ImageView i = new ImageView(mContext);

    i.setImageResource(mThumbIds[position]);
    i.setAdjustViewBounds(true);
    i.setLayoutParams(new Gallery.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    i.setBackgroundResource(R.drawable.picture_frame);
    return i;
}
 
Example 17
@Override
protected void onPostExecute(Void aVoid) {
    super.onPostExecute(aVoid);
    imageView.setLayoutParams(new Gallery.LayoutParams(screenWidth, screenHeight));
    imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
}
 
Example 18
Source Project: anvil   Source File: DSL.java    License: MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult gallery() {
  return BaseDSL.v(Gallery.class);
}
 
Example 19
Source Project: anvil   Source File: DSL.java    License: MIT License 4 votes vote down vote up
public static Void gallery(Anvil.Renderable r) {
  return BaseDSL.v(Gallery.class, r);
}
 
Example 20
Source Project: anvil   Source File: DSL.java    License: MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult gallery() {
  return BaseDSL.v(Gallery.class);
}
 
Example 21
Source Project: anvil   Source File: DSL.java    License: MIT License 4 votes vote down vote up
public static Void gallery(Anvil.Renderable r) {
  return BaseDSL.v(Gallery.class, r);
}
 
Example 22
Source Project: JKCalendar   Source File: JKCalendar.java    License: Apache License 2.0 4 votes vote down vote up
private void initView() {
        //初始化VIEW
//        dateViewpager = (Gallery) findViewById(getResourseIdByName(mContext.getPackageName(),"id","date_viewpager"));
//
//        calendar_month_in_layout = (TextView) findViewById(getResourseIdByName(mContext.getPackageName(),"id","calendar_month_in_layout"));
//        pre_month_icon_in_layout = (TextView) findViewById(getResourseIdByName(mContext.getPackageName(),"id","pre_month_icon_in_layout"));
//        pre_month_in_layout = findViewById(getResourseIdByName(mContext.getPackageName(),"id","pre_month_in_layout"));
//        next_month_icon_in_layout = (TextView) findViewById(getResourseIdByName(mContext.getPackageName(),"id","next_month_icon_in_layout"));
//        next_month_in_layout = findViewById(getResourseIdByName(mContext.getPackageName(),"id","next_month_in_layout"));
//
//        calendar_close = (TextView) findViewById(getResourseIdByName(mContext.getPackageName(),"id","calendar_close"));
//
//        calendar_open = (TextView) findViewById(getResourseIdByName(mContext.getPackageName(),"id","calendar_open"));
//
//        monthText = (TextView) findViewById(getResourseIdByName(mContext.getPackageName(),"id","calendar_month"));
//        preMonth = (TextView) findViewById(getResourseIdByName(mContext.getPackageName(),"id","calendar_pre_month"));
//        nextMonth = (TextView) findViewById(getResourseIdByName(mContext.getPackageName(),"id","calendar_next_month"));
//
//        calendarView = (GridView) findViewById(getResourseIdByName(mContext.getPackageName(),"id","calendar"));
//
//        calendarLayout = (LinearLayout) findViewById(getResourseIdByName(mContext.getPackageName(),"id","calendar_layout"));

        dateViewpager = (Gallery) findViewById(R.id.date_viewpager);

        calendar_month_in_layout = (TextView) findViewById(R.id.calendar_month_in_layout);
        pre_month_icon_in_layout = (TextView) findViewById(R.id.pre_month_icon_in_layout);
        pre_month_in_layout = findViewById(R.id.pre_month_in_layout);
        next_month_icon_in_layout = (TextView) findViewById(R.id.next_month_icon_in_layout);
        next_month_in_layout = findViewById(R.id.next_month_in_layout);

        calendar_close = (TextView) findViewById(R.id.calendar_close);

        calendar_open = (TextView) findViewById(R.id.calendar_open);

        monthText = (TextView) findViewById(R.id.calendar_month);
        preMonth = (TextView) findViewById(R.id.calendar_pre_month);
        nextMonth = (TextView) findViewById(R.id.calendar_next_month);

        calendarView = (GridView) findViewById(R.id.calendar);

        calendarLayout = (LinearLayout) findViewById(R.id.calendar_layout);
    }
 
Example 23
/**
 * {@inheritDoc}
 */
@Override
protected View createView(Context c) {
    LinearLayout soundContainer = new LinearLayout(c);
    soundContainer.setOrientation(LinearLayout.VERTICAL);
    path = Environment.getExternalStorageDirectory().getAbsolutePath()
            + "/testRecording.3gp";

    if (question == null) {
        question = "Record audio:";
    }

    //Set display question
    textViewSound = new TextView(c);
    textViewSound.setText(question);
    textViewSound.setGravity(Gravity.CENTER);
    textViewSound.setTextAppearance(c,
            android.R.style.TextAppearance_Medium);

    //Set accompanying figure
    imageViewSound = new ImageView(c);
    if (!figure.equals("")) {
        try {
            String imagePath = c.getPackageName() + ":" + figure;
            int resID = c.getResources().getIdentifier(imagePath, null,
                    null);
            imageViewSound.setImageResource(resID);
            imageViewSound.setAdjustViewBounds(true); // set the ImageView bounds to match the Drawable's dimensions
            imageViewSound.setLayoutParams(new Gallery.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            imageViewSound.setPadding(10, 10, 10, 10);
        } catch (Exception e) {
            Log.e(TAG, "Couldn't find resource figure " + e.toString());
        }
    }

    //Add to page
    soundContainer.addView(textViewSound,
            new LinearLayout.LayoutParams(-1, -1, 0.1f));
    soundContainer.addView(imageViewSound,
            new LinearLayout.LayoutParams(-1, -1, 0.1f));

    //Initialize audio control buttons
    //Start Record Button
    startRecButt = new Button(c);
    startRecButt.setText("Start Recording");
    startRecButt.setOnClickListener(this);

    //End Record Button (disabled initially)
    endRecButt = new Button(c);
    endRecButt.setText("Stop Recording");
    endRecButt.setEnabled(false);
    endRecButt.setOnClickListener(this);

    //Add to page
    soundContainer.addView(startRecButt,
            new LinearLayout.LayoutParams(-1, -1, 0.1f));
    soundContainer.addView(endRecButt,
            new LinearLayout.LayoutParams(-1, -1, 0.1f));

    return soundContainer;
}
 
Example 24
Source Project: journaldev   Source File: GalleryImageAdapter.java    License: MIT License 3 votes vote down vote up
public View getView(int index, View view, ViewGroup viewGroup)
{
    // TODO Auto-generated method stub
    ImageView i = new ImageView(mContext);

    i.setImageResource(mImageIds[index]);
    i.setLayoutParams(new Gallery.LayoutParams(200, 200));

    i.setScaleType(ImageView.ScaleType.FIT_XY);


    return i;
}
 
Example 25
Source Project: JKCalendar   Source File: CalendarAdapter.java    License: Apache License 2.0 2 votes vote down vote up
@Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHodler viewHodler;

        if (convertView == null) {
//            convertView = layoutInflater.inflate(JKCalendar.getResourseIdByName(mContext.getPackageName(),"layout","calender_adpter_layout"), null);
//
//            viewHodler = new ViewHodler();
//
//            viewHodler.dayOfMonth = (TextView) convertView.findViewById(JKCalendar.getResourseIdByName(mContext.getPackageName(),"id","day_of_month"));
//
//            viewHodler.dayOfWeek = (TextView) convertView.findViewById(JKCalendar.getResourseIdByName(mContext.getPackageName(),"id","day_of_week"));

            convertView = layoutInflater.inflate(R.layout.calender_adpter_layout, null);

            viewHodler = new ViewHodler();

            viewHodler.dayOfMonth = (TextView) convertView.findViewById(R.id.day_of_month);

            viewHodler.dayOfWeek = (TextView) convertView.findViewById(R.id.day_of_week);


            convertView.setTag(viewHodler);
        }

        viewHodler = (ViewHodler) convertView.getTag();

        convertView.setLayoutParams(new Gallery.LayoutParams(convertDipToPixels(mContext,50), convertDipToPixels(mContext,60)));

        Calendar tempCalendar = calendars.get(position);

        viewHodler.dayOfMonth.setText(String.format("%02d",tempCalendar.get(Calendar.DAY_OF_MONTH)));

        viewHodler.dayOfMonth.setTag(tempCalendar);

        SimpleDateFormat parserSDF = new SimpleDateFormat("EEE", Locale.ENGLISH);

        viewHodler.dayOfWeek.setText(parserSDF.format(tempCalendar.getTime()));

        if(clicks.get(position)){
            viewHodler.dayOfWeek.setTextColor(color_high);
            viewHodler.dayOfMonth.setTextColor(color_high);
        }else{
            viewHodler.dayOfWeek.setTextColor(color_hide);
            viewHodler.dayOfMonth.setTextColor(color_hide);
        }

        return convertView;
    }