Example usage for android.widget GridView setAdapter

List of usage examples for android.widget GridView setAdapter

Introduction

In this page you can find the example usage for android.widget GridView setAdapter.

Prototype

@Override
public void setAdapter(ListAdapter adapter) 

Source Link

Document

Sets the data behind this GridView.

Usage

From source file:com.hyperkode.friendshare.fragment.LandingFragment.java

private void setupGridView() {
    GridView grid = (GridView) this.getActivity().findViewById(R.id.gridview);
    grid.setAdapter(new GridAdapter(this.getActivity(), mImagesRes));
    grid.setOnItemClickListener(new OnItemClickListener() {
        @Override//from ww  w. j a v  a 2  s .  c  om
        public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
            Intent i = null;
            switch (pos) {
            case CAMERA_POS:
                //FragmentManager fragmentManager = LandingFragment.this.getActivity().getFragmentManager();
                FragmentManager fm = LandingFragment.this.getActivity().getSupportFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                ft.add(R.id.main_view_containter, LandingFragment.this);
                ft.addToBackStack(null);
                ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
                ft.commit();
                break;

            case MAP_POS:
                //i = new Intent(mThis, TwitterMapViewActivity.class);
                //mThis.startActivity(i);
                break;

            case TWITTER_POS:
                //i = new Intent(mThis, TwitterList.class);
                //mThis.startActivity(i);
                break;
            }
        }
    });
}

From source file:com.example.RITW.proximity.FeaturesActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_features);

    // ensure that Bluetooth exists
    if (!ensureBLEExists())
        finish();//from www. j  a v  a  2s  . c om

    final DrawerLayout drawer = mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    // Set the drawer toggle as the DrawerListener
    drawer.setDrawerListener(mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
            R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close));

    // setup plug-ins in the drawer
    //setupPluginsInDrawer((ViewGroup) drawer.findViewById(R.id.plugin_container));

    // configure the app grid
    final GridView grid = (GridView) findViewById(R.id.grid);
    grid.setAdapter(new AppAdapter(this));
    grid.setEmptyView(findViewById(android.R.id.empty));

    getActionBar().setDisplayHomeAsUpEnabled(true);
}

From source file:com.z299studio.pb.IconSetter.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView;/*  ww w. ja v  a  2  s. c om*/
    if (Application.getInstance() == null || Application.getInstance().getAccountManager() == null) {
        return null;
    }
    if (savedInstanceState != null) {
        mImg = savedInstanceState.getInt("img_code");
    }
    rootView = inflater.inflate(R.layout.dialog_choose_icon, container);
    Button button = (Button) rootView.findViewById(R.id.ok);
    button.setOnClickListener(this);
    button = (Button) rootView.findViewById(R.id.cancel);
    button.setOnClickListener(this);
    final ImageAdapter imageAdapter = new ImageAdapter(getActivity());
    if (mImg > 0) {
        imageAdapter.checkItem(null, mImg);
    }
    GridView gridView = (GridView) rootView.findViewById(R.id.icon);
    gridView.setAdapter(imageAdapter);
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
            mImg = pos;
            imageAdapter.checkItem(view, pos);
        }
    });

    return rootView;
}

From source file:com.cmput301.classproject.UI.SubmissionViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_submission_view);
    getActionBar().setDisplayHomeAsUpEnabled(false);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        this.submission = (Submission) extras.getSerializable("Submission");
    }/*from w ww.ja  va2  s  .  c om*/

    if (submission == null) {
        finish();
    } else {

        submissionPhotos = submission.getImages();

        // Start recognizing the Layout elements.
        GridView gridView = (GridView) findViewById(R.id.submissionPhotoList);
        gridView.setAdapter(new ImageAdapter(this));

        // Fill out activity view using the submission object
        TextView authorText = (TextView) findViewById(R.id.view_author_name);
        authorText.setText(submission.getAuthor());

        TextView submissionSummary = (TextView) findViewById(R.id.view_submission_summary);
        submissionSummary.setText(submission.getSummary());

        TextView submissionText = (TextView) findViewById(R.id.view_submission_text);
        submissionText.setText(submission.getTextSubmission());

        TextView access = (TextView) findViewById(R.id.view_submission_access);
        access.setText(submission.getAccess().toString());

        // TODO display timestamp, at the moment we only save it.
    }

}

From source file:org.libreoffice.impressremote.fragment.slides.SlidesGridFragment.java

@Override
public void onServiceConnected(ComponentName aComponentName, IBinder aBinder) {
    CommunicationService.ServiceBinder aServiceBinder = (CommunicationService.ServiceBinder) aBinder;
    mCommunicationService = aServiceBinder.getService();

    if (!isAdded()) {
        return;/*from w  w w  .j av  a2s .c o m*/
    }

    GridView aSlidesGrid = getSlidesGrid();
    if (null == aSlidesGrid)
        return;

    aSlidesGrid.setAdapter(buildSlidesAdapter());
    aSlidesGrid.setOnItemClickListener(this);

    mCurrentSlideIndex = mCommunicationService.getSlideShow().getCurrentSlideIndex();
}

From source file:com.github.andrewlord1990.materialandroidsample.color.ColorChooserDialog.java

private View setupCustomView(final AlertDialog dialog) {
    Context context = dialog.getContext();
    View customView = LayoutInflater.from(context).inflate(R.layout.color_chooser, null);
    GridView grid = (GridView) customView.findViewById(R.id.colorChooserGrid);
    ColorGridAdapter adapter = new ColorGridAdapter(context, colors);
    grid.setAdapter(adapter);
    grid.setOnItemClickListener(new OnItemClickListener() {
        @Override//  w  w w .  j a  va2 s  .  co  m
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (listener != null) {
                listener.onColorSelected(requestCode, colors.get(position));
            }
            dialog.dismiss();
        }
    });
    return customView;
}

From source file:com.pureexe.calinoius.environment.camera.fragment.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    dataManager = new DataManager(getActivity());

    try {/*  w w w  .j av a 2s  .com*/
        // Use Try catch Exception to avoid force close with CM's Privacy Guard
        Cursor c = getActivity().getApplication().getContentResolver()
                .query(ContactsContract.Profile.CONTENT_URI, null, null, null, null);
        c.moveToFirst();
        dataManager.setString("Researcher", c.getString(c.getColumnIndex("display_name")));
    } catch (Exception e) {
        dataManager.setString("Researcher", "Unknown");
    }
    GridView gridview = (GridView) rootView.findViewById(R.id.gridView1);
    gridview.setAdapter(new HomePageAdapter(getActivity()));
    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            if (position == 0) {
                Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class);
                beepActivity.setAction(Intent.ACTION_SEND);
                beepActivity.putExtra(Intent.EXTRA_TEXT, "UserFragment");
                beepActivity.setType("beepActivity");
                startActivity(beepActivity);
            }
            if (position == 1) {
                Intent intent = new Intent(getActivity(), EnvironmentCameraActivity.class);
                startActivity(intent);
            }
            if (position == 2) {
                Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class);
                beepActivity.setAction(Intent.ACTION_SEND);
                beepActivity.putExtra(Intent.EXTRA_TEXT, "EXIFreadFragment");
                beepActivity.setType("beepActivity");
                startActivity(beepActivity);
            }
            if (position == 3) {
                Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class);
                beepActivity.setAction(Intent.ACTION_SEND);
                beepActivity.putExtra(Intent.EXTRA_TEXT, "SettingPreferenceFragment");
                beepActivity.setType("beepActivity");
                startActivity(beepActivity);
            }
            if (position == 4) {
                Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class);
                beepActivity.setAction(Intent.ACTION_SEND);
                beepActivity.putExtra(Intent.EXTRA_TEXT, "HelpFragment");
                beepActivity.setType("beepActivity");
                startActivity(beepActivity);
            }
            if (position == 5) {
                Intent beepActivity = new Intent(getActivity(), FragmentDisplayActivity.class);
                beepActivity.setAction(Intent.ACTION_SEND);
                beepActivity.putExtra(Intent.EXTRA_TEXT, "AboutFragment");
                beepActivity.setType("beepActivity");
                startActivity(beepActivity);
            }
        }
    });

    return rootView;
}

From source file:com.example.picassotransformations.GridFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.grid, container, false);

    mImageView = (ImageView) view.findViewById(R.id.image);
    mImageView.setOnClickListener(new View.OnClickListener() {

        @Override// w w w. ja v a  2s  .  c  om
        public void onClick(View v) {
            v.setVisibility(View.GONE);
        }
    });

    GridView grid = (GridView) view.findViewById(R.id.grid);
    GridAdapter adapter = new GridAdapter(getActivity(), mCategory.getTransformations(), TULIP_IMG_URL);
    grid.setAdapter(adapter);

    adapter.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int position = (Integer) v.getTag();
            Picasso.with(getActivity()).load(TULIP_IMG_URL)
                    .transform(mCategory.getTransformations().get(position)).centerInside().fit()
                    .into(mImageView);
            mImageView.setVisibility(View.VISIBLE);
        }
    });

    return view;
}

From source file:net.pejici.easydice.fragment.DiceRollerFragment.java

private void setupDiceHand(View rootView) {
    GridView grid = (GridView) rootView.findViewById(R.id.dice_grid);
    handAdapter = new DieViewDieHandAdapter(this.getActivity(), hand);
    grid.setAdapter(handAdapter);
    OnItemClickListener cl = new OnItemClickListener() {
        @Override/*from w  w w  .  ja va2s.  c o m*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            DieView dieView = (DieView) view;
            hand.setSelected(position, !dieView.getSelected());
        }
    };
    grid.setOnItemClickListener(cl);
}

From source file:com.donal.superne.app.ui.chat.emojicon.EmojiconGridFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView);
    mData = getArguments() == null ? People.DATA : (Emojicon[]) getArguments().getSerializable("emojicons");
    gridView.setAdapter(new EmojiAdapter(view.getContext(), mData));
    gridView.setOnItemClickListener(this);
}