Search in sources :

Example 61 with GridView

use of android.widget.GridView in project LiveLessons by douglascraigschmidt.

the class ResultsActivity method addResultButton.

/**
     * Add a button with the given filterName as its text.  This
     * button will load the results of the given filter into the
     * GridView
     */
@SuppressLint("InflateParams")
private void addResultButton(String filterName) {
    // Create a new button with the layout of "result_button".
    Button resultButton = (Button) LayoutInflater.from(this).inflate(R.layout.result_button, null);
    // Set the new button's text and tag to the filter name.
    resultButton.setText(filterName);
    resultButton.setTag(filterName);
    // When the button is clicked, change the imageAdapter source
    // to the appropriate filter directory.
    resultButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            Button button = (Button) view;
            // Find the filter directory and load the
            // directory as the source of the imageAdapter.
            imageAdapter.setBitmaps(new File(Options.instance().getDirectoryPath(), button.getText().toString()).getAbsolutePath());
        }
    });
    // Add the button to the layout.
    mLayout.addView(resultButton);
}
Also used : Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) File(java.io.File) SuppressLint(android.annotation.SuppressLint)

Example 62 with GridView

use of android.widget.GridView in project android_frameworks_base by DirtyUnicorns.

the class GridScenario method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    // turn off title bar
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mScreenHeight = getWindowManager().getDefaultDisplay().getHeight();
    final Params params = new Params();
    init(params);
    readAndValidateParams(params);
    mGridView = new GridView(this);
    mGridView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mGridView.setDrawSelectorOnTop(false);
    if (mNumColumns >= GridView.AUTO_FIT) {
        mGridView.setNumColumns(mNumColumns);
    }
    if (mColumnWidth > 0) {
        mGridView.setColumnWidth(mColumnWidth);
    }
    if (mVerticalSpacing > 0) {
        mGridView.setVerticalSpacing(mVerticalSpacing);
    }
    mGridView.setStretchMode(mStretchMode);
    mGridView.setAdapter(createAdapter());
    if (mStartingSelectionPosition >= 0) {
        mGridView.setSelection(mStartingSelectionPosition);
    }
    mGridView.setPadding(10, 10, 10, 10);
    mGridView.setStackFromBottom(mStackFromBottom);
    mGridView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        public void onItemSelected(AdapterView parent, View v, int position, long id) {
            positionSelected(position);
        }

        public void onNothingSelected(AdapterView parent) {
            nothingSelected();
        }
    });
    setContentView(mGridView);
}
Also used : ViewGroup(android.view.ViewGroup) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView) GridView(android.widget.GridView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 63 with GridView

use of android.widget.GridView in project CurtainView by aicaprio.

the class MainActivity method showSample2.

private void showSample2() {
    setContentView(R.layout.activity_sample2);
    final CurtainView curtainView = (CurtainView) findViewById(R.id.cb1);
    final ImageView iv1 = (ImageView) findViewById(R.id.iv1);
    final GridView gv1 = (GridView) findViewById(R.id.gv1);
    final List<Map<String, Integer>> data = getData();
    gv1.setAdapter(new SimpleAdapter(this, data, R.layout.item_numbers, new String[] { TEXT_TAG }, new int[] { R.id.item_tvNum }));
    gv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            showToast(data.get(position).get(TEXT_TAG) + " clicked");
        }
    });
    iv1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            curtainView.toggleStatus();
        }
    });
    curtainView.setScrollerInterpolator(new BounceInterpolator());
    curtainView.post(new Runnable() {

        @Override
        public void run() {
            curtainView.setCurtainGravityAndFixedValue(null, iv1.getHeight());
        }
    });
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) SimpleAdapter(android.widget.SimpleAdapter) GridView(android.widget.GridView) CurtainView(org.aicaprio.curtainview.CurtainView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) CurtainView(org.aicaprio.curtainview.CurtainView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) GridView(android.widget.GridView) HashMap(java.util.HashMap) Map(java.util.Map)

Example 64 with GridView

use of android.widget.GridView in project emojicon by rockerhieu.

the class EmojiconGridFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView);
    Bundle bundle = getArguments();
    if (bundle == null) {
        mEmojiconType = Emojicon.TYPE_UNDEFINED;
        mEmojicons = People.DATA;
        mUseSystemDefault = false;
    } else {
        // noinspection WrongConstant
        mEmojiconType = bundle.getInt(ARG_EMOJICON_TYPE);
        if (mEmojiconType == Emojicon.TYPE_UNDEFINED) {
            Parcelable[] parcels = bundle.getParcelableArray(ARG_EMOJICONS);
            mEmojicons = new Emojicon[parcels.length];
            for (int i = 0; i < parcels.length; i++) {
                mEmojicons[i] = (Emojicon) parcels[i];
            }
        } else {
            mEmojicons = Emojicon.getEmojicons(mEmojiconType);
        }
        mUseSystemDefault = bundle.getBoolean(ARG_USE_SYSTEM_DEFAULTS);
    }
    gridView.setAdapter(new EmojiconAdapter(view.getContext(), mEmojicons, mUseSystemDefault));
    gridView.setOnItemClickListener(this);
}
Also used : Bundle(android.os.Bundle) Parcelable(android.os.Parcelable) GridView(android.widget.GridView)

Example 65 with GridView

use of android.widget.GridView in project SmartCampus by Vegen.

the class EaseEmojiconPagerView method getGroupGridViews.

/**
 * get emojicon group gridview list
 * @param groupEntity
 * @return
 */
public List<View> getGroupGridViews(EaseEmojiconGroupEntity groupEntity) {
    List<EaseEmojicon> emojiconList = groupEntity.getEmojiconList();
    int itemSize = emojiconColumns * emojiconRows - 1;
    int totalSize = emojiconList.size();
    Type emojiType = groupEntity.getType();
    if (emojiType == Type.BIG_EXPRESSION) {
        itemSize = bigEmojiconColumns * bigEmojiconRows;
    }
    int pageSize = totalSize % itemSize == 0 ? totalSize / itemSize : totalSize / itemSize + 1;
    List<View> views = new ArrayList<View>();
    for (int i = 0; i < pageSize; i++) {
        View view = View.inflate(context, R.layout.ease_expression_gridview, null);
        GridView gv = (GridView) view.findViewById(R.id.gridview);
        if (emojiType == Type.BIG_EXPRESSION) {
            gv.setNumColumns(bigEmojiconColumns);
        } else {
            gv.setNumColumns(emojiconColumns);
        }
        List<EaseEmojicon> list = new ArrayList<EaseEmojicon>();
        if (i != pageSize - 1) {
            list.addAll(emojiconList.subList(i * itemSize, (i + 1) * itemSize));
        } else {
            list.addAll(emojiconList.subList(i * itemSize, totalSize));
        }
        if (emojiType != Type.BIG_EXPRESSION) {
            EaseEmojicon deleteIcon = new EaseEmojicon();
            deleteIcon.setEmojiText(EaseSmileUtils.DELETE_KEY);
            list.add(deleteIcon);
        }
        final EmojiconGridAdapter gridAdapter = new EmojiconGridAdapter(context, 1, list, emojiType);
        gv.setAdapter(gridAdapter);
        gv.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                EaseEmojicon emojicon = gridAdapter.getItem(position);
                if (pagerViewListener != null) {
                    String emojiText = emojicon.getEmojiText();
                    if (emojiText != null && emojiText.equals(EaseSmileUtils.DELETE_KEY)) {
                        pagerViewListener.onDeleteImageClicked();
                    } else {
                        pagerViewListener.onExpressionClicked(emojicon);
                    }
                }
            }
        });
        views.add(view);
    }
    return views;
}
Also used : EmojiconGridAdapter(com.hyphenate.easeui.adapter.EmojiconGridAdapter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) Type(com.hyphenate.easeui.domain.EaseEmojicon.Type) EaseEmojicon(com.hyphenate.easeui.domain.EaseEmojicon) GridView(android.widget.GridView)

Aggregations

GridView (android.widget.GridView)142 View (android.view.View)86 AdapterView (android.widget.AdapterView)64 TextView (android.widget.TextView)42 ImageView (android.widget.ImageView)30 AbsListView (android.widget.AbsListView)20 Intent (android.content.Intent)15 ViewGroup (android.view.ViewGroup)14 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)11 SuppressLint (android.annotation.SuppressLint)10 ArrayList (java.util.ArrayList)9 LayoutInflater (android.view.LayoutInflater)8 WindowManager (android.view.WindowManager)7 Button (android.widget.Button)7 ColorDrawable (android.graphics.drawable.ColorDrawable)6 ListView (android.widget.ListView)6 LinearLayout (android.widget.LinearLayout)5 Bundle (android.os.Bundle)4 ViewTreeObserver (android.view.ViewTreeObserver)4 ArrayAdapter (android.widget.ArrayAdapter)4