android.widget.Gallery Java Examples

The following examples show how to use android.widget.Gallery. 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 check out the related API usage on the sidebar.
Example #1
Source File: GPUFilterAdapter.java    From DevUtils with 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 #2
Source File: GPUFilterACVAdapter.java    From DevUtils with 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 #3
Source File: FullscreenImageActivity.java    From YalpStore with GNU General Public License v2.0 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 #4
Source File: ImageSwitcher1.java    From codeexamples-android with Eclipse Public License 1.0 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 #5
Source File: ImageAdapter.java    From YalpStore with 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 #6
Source File: Gallery2.java    From codeexamples-android with 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 #7
Source File: GalleryAdapter.java    From mobile-manager-tool with 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 #8
Source File: GalleryImageAdapter.java    From Field-Book with GNU General Public License v2.0 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 #9
Source File: ImageSwitcher1.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
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 #10
Source File: ImageFilterActivity.java    From UltimateAndroid with 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 #11
Source File: ImageFilterActivity.java    From UltimateAndroid with 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 #12
Source File: BbCodesPanel.java    From 4pdaClient-plus with 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 #13
Source File: BbCodesBasePanel.java    From 4pdaClient-plus with 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 #14
Source File: MyImageAdapter.java    From Android-HowOld with 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 #15
Source File: FaceActivity.java    From Android-HowOld with 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 #16
Source File: BannerViewPager.java    From ShoppingCartActivity with 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 #17
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void gallery(Anvil.Renderable r) {
  return BaseDSL.v(Gallery.class, r);
}
 
Example #18
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult gallery() {
  return BaseDSL.v(Gallery.class);
}
 
Example #19
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void gallery(Anvil.Renderable r) {
  return BaseDSL.v(Gallery.class, r);
}
 
Example #20
Source File: JKCalendar.java    From JKCalendar with 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 #21
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult gallery() {
  return BaseDSL.v(Gallery.class);
}
 
Example #22
Source File: SoundElement.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * {@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 #23
Source File: FullscreenImageAdapter.java    From YalpStore with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onPostExecute(Void aVoid) {
    super.onPostExecute(aVoid);
    imageView.setLayoutParams(new Gallery.LayoutParams(screenWidth, screenHeight));
    imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
}
 
Example #24
Source File: GalleryImageAdapter.java    From journaldev with 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 File: CalendarAdapter.java    From JKCalendar with 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;
    }