Example usage for android.widget AdapterView getAdapter

List of usage examples for android.widget AdapterView getAdapter

Introduction

In this page you can find the example usage for android.widget AdapterView getAdapter.

Prototype

public abstract T getAdapter();

Source Link

Document

Returns the adapter currently associated with this widget.

Usage

From source file:com.optimusinfo.elasticpath.cortex.common.Utils.java

@SuppressWarnings("rawtypes")
public static int getTotalHeightofListView(AdapterView argAdapterView) {
    Adapter mAdapter = argAdapterView.getAdapter();
    if (mAdapter == null) {
        // pre-condition
        return 0;
    }/*from  ww w . j a  v  a  2  s  .  c  om*/
    int totalHeight = 0;
    for (int i = 0; i < mAdapter.getCount(); i++) {
        View mView = mAdapter.getView(i, null, argAdapterView);
        mView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        mView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        totalHeight += mView.getMeasuredHeight();
    }
    return totalHeight;
}

From source file:io.pivotal.arca.fragments.ArcaAdapterSupportFragment.java

public CursorAdapter getCursorAdapter() {
    final AdapterView<CursorAdapter> adapterView = getAdapterView();
    if (adapterView != null) {
        return adapterView.getAdapter();
    } else {//from  w ww . jav  a  2  s  .c om
        return null;
    }
}

From source file:rss.RssFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    RssAdapter adapter = (RssAdapter) parent.getAdapter();
    RssItem item = (RssItem) adapter.getItem(position);

    weatherLink = item.getLink();//from  w ww.  ja  v a  2s  . c  o m
    weatherDesc = item.getDesc();

    //        Uri uri = Uri.parse(item.getLink());
    //        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    //        startActivity(intent);

    Intent intent = new Intent(getActivity(), RssActivity.class);
    startActivity(intent);
}

From source file:org.kaaproject.kaa.demo.smarthousedemo.smarthouse.HomeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_home, container, false);
    ListView homeListView = (ListView) view.findViewById(R.id.homeList);

    homeListView.setAdapter(mSectionAdapter);

    homeListView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Object item = parent.getAdapter().getItem(position);
            if (item instanceof DeviceType) {
                mActivity.switchToDeviceType((DeviceType) item);
            }//ww  w . j  a  v a2 s.c  o m
        }
    });

    return view;
}

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

private void setupDiceButtons(View rootView) {
    GridView buttonGrid = (GridView) rootView.findViewById(R.id.dice_buttons_grid);
    DieViewArrayAdapter<Die> adapter = new DieViewArrayAdapter<Die>(this.getActivity(), 0,
            Die.allLargestSizeDice());//from   w  w  w .j  a  va2  s .c om
    buttonGrid.setAdapter(adapter);
    OnItemClickListener cl = new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View dieView, int position, long id) {
            Die die = (Die) parent.getAdapter().getItem(position);
            hand.addDie(die);
        }
    };
    buttonGrid.setOnItemClickListener(cl);
}

From source file:com.codeherenow.navigationdrawer.NavigationDrawerActivity.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    // Show a toast
    Adapter adapter = parent.getAdapter();
    String website = adapter.getItem(position).toString();
    Toast.makeText(this, website, Toast.LENGTH_SHORT).show();

    // Dismiss the drawer
    if (mDrawerLayout.isDrawerOpen(mDrawerListView)) {
        mDrawerLayout.closeDrawer(mDrawerListView);
    }//from   w w w  .j  a va 2s  . co  m
}

From source file:org.xbmc.android.remotesandbox.ui.phone.DashboardFragment.java

private OnItemClickListener getHomeMenuOnClickListener() {
    return new OnItemClickListener() {

        public void onItemClick(AdapterView<?> listView, View v, int position, long ID) {
            HomeItem item = (HomeItem) listView.getAdapter().getItem(position);
            Intent intent = null;//from   ww w.ja  v  a 2  s .  c o m
            switch (item.ID) {
            case HOME_ACTION_REMOTE:
            case HOME_ACTION_MUSIC:
            case HOME_ACTION_VIDEOS:
                intent = new Intent(v.getContext(), MusicPagerActivity.class);
                break;
            }
            if (intent != null) {
                getActivity().startActivity(intent);
            }
        }

    };
}

From source file:com.gh4a.fragment.PullRequestCommitListFragment.java

public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
    RepositoryCommit commit = (RepositoryCommit) adapterView.getAdapter().getItem(position);
    Intent intent = new Intent().setClass(getSherlockActivity(), CommitActivity.class);

    intent.putExtra(Constants.Repository.REPO_OWNER, mRepoOwner);
    intent.putExtra(Constants.Repository.REPO_NAME, mRepoName);
    intent.putExtra(Constants.Object.OBJECT_SHA, commit.getSha());
    intent.putExtra(Constants.Object.TREE_SHA, commit.getCommit().getTree().getSha());

    startActivity(intent);/*from  ww w. j  a  v a 2s . c o m*/
}

From source file:at.bitfire.davdroid.mirakel.syncadapter.LoginURLFragment.java

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

    // protocol selection spinner
    textHttpWarning = (TextView) v.findViewById(R.id.http_warning);

    Spinner spnrScheme = (Spinner) v.findViewById(R.id.login_scheme);
    spnrScheme.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override//from  ww w . ja v  a  2 s. c o  m
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            scheme = parent.getAdapter().getItem(position).toString();
            textHttpWarning.setVisibility(scheme.equals("https://") ? View.GONE : View.VISIBLE);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            scheme = null;
        }
    });
    spnrScheme.setSelection(1); // HTTPS

    // other input fields
    editBaseURI = (EditText) v.findViewById(R.id.login_host_path);
    editBaseURI.addTextChangedListener(this);

    editUserName = (EditText) v.findViewById(R.id.userName);
    editUserName.addTextChangedListener(this);

    editPassword = (EditText) v.findViewById(R.id.password);
    editPassword.addTextChangedListener(this);

    checkboxPreemptive = (CheckBox) v.findViewById(R.id.auth_preemptive);

    // hook into action bar
    setHasOptionsMenu(true);

    return v;
}

From source file:com.blandware.android.atleap.sample.ui.MasterFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    SimpleCursorAdapterLoadable adapter = new SimpleCursorAdapterLoadable(getActivity(),
            DefaultContract.CONTENT_URI_REPOSITORIES_USERS,
            new String[] {
                    DefaultContract.Repository.TABLE + "." + DefaultContract.Repository._ID + " AS "
                            + DefaultContract.Repository._ID,
                    DefaultContract.User.AVATAR_URL, DefaultContract.Repository.FULL_NAME,
                    DefaultContract.Repository.STARGAZERS_COUNT, DefaultContract.Repository.DESCRIPTION },
            null, //selection
            null, //selectionArgs
            DefaultContract.Repository.STARGAZERS_COUNT + " DESC", //sortOrder
            R.layout.listitem_repository,
            new String[] { DefaultContract.User.AVATAR_URL, DefaultContract.Repository.FULL_NAME,
                    DefaultContract.Repository.STARGAZERS_COUNT, DefaultContract.Repository.DESCRIPTION },
            new int[] { R.id.avatar_url, R.id.full_name, R.id.stargazers_count, R.id.description });
    LoaderManagerCreator loaderManagerCreator = new LoaderManagerCreator(this, adapter);

    ListView listView = (ListView) getView().findViewById(R.id.list_repositories);
    listView.setAdapter(adapter);//w  ww. j a v  a 2  s .c  o m

    adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
        @Override
        public boolean setViewValue(View view, Cursor cursor, int i) {
            if (view.getId() == R.id.avatar_url) {
                ImageView imageView = (ImageView) view;
                String avatarUrl = cursor.getString(i);
                Picasso.with(getActivity()).load(avatarUrl).into(imageView);
                return true;
            } else {
                return false;
            }
        }
    });

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor cursor = (Cursor) parent.getAdapter().getItem(position);
            int repositoryId = cursor.getInt(cursor.getColumnIndex(DefaultContract.Repository._ID));
            NavUtil.replaceFragment(getActivity(), R.id.container, DetailFragment.newInstance(repositoryId));
        }
    });
}