Search in sources :

Example 36 with GridView

use of android.widget.GridView in project facebook-android-sdk by facebook.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    gameController = new GameController(this, getIntent());
    board = (GridView) findViewById(R.id.board);
    validNumbers = (GridView) findViewById(R.id.valid_numbers);
    gameController.setBoardView(board);
    gameController.setSelectionView(validNumbers);
    Button newGame = (Button) findViewById(R.id.new_board);
    newGame.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            gameController.newGame();
        }
    });
    Button clearBoard = (Button) findViewById(R.id.clear_board);
    clearBoard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            gameController.clearBoard();
        }
    });
    final ShareButton share = (ShareButton) findViewById(R.id.share_button);
    share.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            share.setShareContent(getLinkContent());
        }
    });
    final SendButton send = (SendButton) findViewById(R.id.send_button);
    send.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            send.setShareContent(getLinkContent());
        }
    });
    Button copy = (Button) findViewById(R.id.copy_button);
    copy.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newUri(getContentResolver(), "Iconicus", gameController.getShareUri());
            clipboard.setPrimaryClip(clip);
            Toast.makeText(MainActivity.this, R.string.link_copied, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : ClipboardManager(android.content.ClipboardManager) SendButton(com.facebook.share.widget.SendButton) ShareButton(com.facebook.share.widget.ShareButton) Button(android.widget.Button) SendButton(com.facebook.share.widget.SendButton) GridView(android.widget.GridView) View(android.view.View) ShareButton(com.facebook.share.widget.ShareButton) ClipData(android.content.ClipData)

Example 37 with GridView

use of android.widget.GridView in project android-topeka by googlesamples.

the class SignInFragment method setUpGridView.

private void setUpGridView(View container) {
    mAvatarGrid = (GridView) container.findViewById(R.id.avatars);
    mAvatarGrid.setAdapter(new AvatarAdapter(getActivity()));
    mAvatarGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mSelectedAvatarView = view;
            mSelectedAvatar = Avatar.values()[position];
            // showing the floating action button if input data is valid
            if (isInputDataValid()) {
                mDoneFab.show();
            }
        }
    });
    mAvatarGrid.setNumColumns(calculateSpanCount());
    if (mSelectedAvatar != null) {
        mAvatarGrid.setItemChecked(mSelectedAvatar.ordinal(), true);
    }
}
Also used : AvatarAdapter(com.google.samples.apps.topeka.adapter.AvatarAdapter) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 38 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 39 with GridView

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

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

use of android.widget.GridView in project ApertureGallery by MJonesDev.

the class AlbumActivity method initializeView.

private void initializeView() {
    mView = (GridView) findViewById(com.marlonjones.projectevo.R.id.grid_view);
    mView.setAdapter(listAdapter = new ListAdapter(AlbumActivity.this));
    int position = mView.getFirstVisiblePosition();
    int columnsCount = 3;
    mView.setNumColumns(columnsCount);
    itemWidth = (ApertureBasing.displaySize.x - ((columnsCount + 2) * ApertureBasing.dp(4))) / columnsCount;
    mView.setColumnWidth(itemWidth);
    listAdapter.notifyDataSetChanged();
    mView.setSelection(position);
    mView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            Intent mIntent = new Intent(AlbumActivity.this, PhotoPreviewActivity.class);
            Bundle mBundle = new Bundle();
            mBundle.putInt("Key_FolderID", AlbummID);
            mBundle.putInt("Key_ID", position);
            mIntent.putExtras(mBundle);
            startActivity(mIntent);
        }
    });
    LoadAllAlbum();
}
Also used : Bundle(android.os.Bundle) AdapterView(android.widget.AdapterView) Intent(android.content.Intent) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) 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