Search in sources :

Example 96 with GridView

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

the class EmojiconRecentsGridFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    EmojiconRecentsManager recents = EmojiconRecentsManager.getInstance(view.getContext());
    mAdapter = new EmojiconAdapter(view.getContext(), recents, mUseSystemDefault);
    GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView);
    gridView.setAdapter(mAdapter);
    gridView.setOnItemClickListener(this);
}
Also used : GridView(android.widget.GridView)

Example 97 with GridView

use of android.widget.GridView in project platform_frameworks_base by android.

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 98 with GridView

use of android.widget.GridView in project platform_frameworks_base by android.

the class GridThrasher method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.grid_thrasher);
    mText = (TextView) findViewById(R.id.text);
    mAdapter = new ThrashListAdapter(this);
    GridView g = (GridView) findViewById(R.id.grid);
    g.setAdapter(mAdapter);
    mHandler.postDelayed(mThrash, 5000);
    g.setOnItemSelectedListener(this);
}
Also used : GridView(android.widget.GridView)

Example 99 with GridView

use of android.widget.GridView in project AndroidDynamicLoader by mmin18.

the class ImageGridFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    MyResources res = MyResources.getResource(ImageGridFragment.class);
    final View v = res.inflate(getActivity(), R.layout.image_grid_fragment, container, false);
    final GridView mGridView = (GridView) v.findViewById(R.id.gridView);
    mGridView.setAdapter(mAdapter);
    mGridView.setOnItemClickListener(this);
    mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView absListView, int scrollState) {
            // Pause fetcher to ensure smoother scrolling when flinging
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
                mImageFetcher.setPauseWork(true);
            } else {
                mImageFetcher.setPauseWork(false);
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        }
    });
    // This listener is used to get the final width of the GridView and then calculate the
    // number of columns and the width of each column. The width of each column is variable
    // as the GridView has stretchMode=columnWidth. The column width is used to set the height
    // of each view so we get nice square thumbnails.
    mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            if (mAdapter.getNumColumns() == 0) {
                final int numColumns = (int) Math.floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing));
                if (numColumns > 0) {
                    final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing;
                    mAdapter.setNumColumns(numColumns);
                    mAdapter.setItemHeight(columnWidth);
                    Log.d(TAG, "onCreateView - numColumns set to " + numColumns);
                }
            }
        }
    });
    return v;
}
Also used : MyResources(com.dianping.loader.MyResources) AbsListView(android.widget.AbsListView) GridView(android.widget.GridView) GridView(android.widget.GridView) ImageView(android.widget.ImageView) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ViewTreeObserver(android.view.ViewTreeObserver)

Example 100 with GridView

use of android.widget.GridView in project ButterRemote-Android by se-bastiaan.

the class DonationFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();
    assert activity != null;
    View view = getActivity().getLayoutInflater().inflate(R.layout.donation_dialog, null, false);
    AlertDialog.Builder builder = new AlertDialog.Builder(activity).setTitle(R.string.donation_title).setView(view).setNegativeButton(android.R.string.cancel, null);
    TextView info = (TextView) view.findViewById(R.id.info);
    info.setText(Html.fromHtml(getString(R.string.donation_info)));
    info.setMovementMethod(new LinkMovementMethod());
    mError = (TextView) view.findViewById(R.id.error);
    mProgressBar = (ProgressBar) view.findViewById(android.R.id.progress);
    mGridView = (GridView) view.findViewById(R.id.grid);
    mGridView.setAdapter(new DonationAdapter(getActivity(), mDonationList, mInventorySet));
    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            DonationAdapter adapter = (DonationAdapter) parent.getAdapter();
            Donation donation = adapter.getItem(position);
            if (!mInventorySet.contains(donation.sku)) {
                /**
                     * See {@link sharedcode.turboeditor.iab.DonationFragment#verifyDeveloperPayload(Purchase)}.
                     */
                String payload = "";
                try {
                    mHelper.launchPurchaseFlow(getActivity(), donation.sku, RC_REQUEST, mPurchaseFinishedListener, payload);
                } catch (Exception e) {
                    Toast.makeText(getActivity(), "Failed to launch a purchase flow.", Toast.LENGTH_SHORT).show();
                }
            } else {
                Toast.makeText(getActivity(), getString(R.string.donation_item_bought), Toast.LENGTH_LONG);
            }
        }
    });
    final AlertDialog alertDialog;
    alertDialog = builder.create();
    initBilling();
    return alertDialog;
}
Also used : AlertDialog(android.app.AlertDialog) Activity(android.app.Activity) LinkMovementMethod(android.text.method.LinkMovementMethod) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ActivityNotFoundException(android.content.ActivityNotFoundException) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView)

Aggregations

GridView (android.widget.GridView)139 View (android.view.View)83 AdapterView (android.widget.AdapterView)61 TextView (android.widget.TextView)41 ImageView (android.widget.ImageView)28 AbsListView (android.widget.AbsListView)20 Intent (android.content.Intent)14 ViewGroup (android.view.ViewGroup)14 SuppressLint (android.annotation.SuppressLint)10 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)10 LayoutInflater (android.view.LayoutInflater)8 ArrayList (java.util.ArrayList)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