Java Code Examples for android.widget.ListAdapter

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 2

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 3

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 4

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 5

From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/base/.

Source file: ListActivityBase.java

  18 
vote

protected void notifyDataSetChanged(){
  ListAdapter listAdapter=getListAdapter();
  if (listAdapter != null && listAdapter instanceof ArrayAdapter) {
    ((ArrayAdapter<?>)listAdapter).notifyDataSetChanged();
  }
 else {
    Log.w(TAG,"Could not update list Array Adapter");
  }
}
 

Example 6

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 7

From project Android-SQL-Helper, under directory /tests/AndroidSampleProject/src/com/sgxmobileapps/androidsqlhelper/example/.

Source file: UserListActivity.java

  18 
vote

@Override protected void onResume(){
  super.onResume();
  mDbAdapter.open();
  Cursor cursor=mDbAdapter.getCursorAppUser();
  startManagingCursor(cursor);
  ListAdapter adapter=new SimpleCursorAdapter(this,android.R.layout.two_line_list_item,cursor,new String[]{StorageDbMetadata.AppUser.APPUSER_FIRSTNAME_COL,StorageDbMetadata.AppUser.APPUSER_SURNAME_COL},new int[]{android.R.id.text1,android.R.id.text2});
  setListAdapter(adapter);
}
 

Example 8

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 9

From project android_8, under directory /src/com/defuzeme/playqueue/.

Source file: PlayQueue.java

  18 
vote

public void onRemove(int which){
  final ListAdapter ladapter=getListAdapter();
  if (ladapter instanceof QueueAdapter) {
    ((QueueAdapter)ladapter).onRemove(which);
    getListView().invalidateViews();
    if (listView instanceof DnDList) {
      ((DnDList)listView).setRemoveListener(mRemoveListener);
      ((DnDList)listView).setDropListener(mDropListener);
      ((DnDList)listView).setDragListener(mDragListener);
    }
    _adapter.notifyDataSetChanged();
  }
}
 

Example 10

From project android_packages_apps_CMSettings, under directory /src/com/cyanogenmod/settings/.

Source file: SlideSettings.java

  18 
vote

@Override public void onListItemClick(ListView l,View v,int position,long id){
  ListAdapter adapter=getListAdapter();
  Headers header=(Headers)adapter.getItem(position);
  if (!TextUtils.isEmpty(header.mFragment)) {
    Intent intent=new Intent(Intent.ACTION_MAIN);
    intent.setClassName(getActivity().getApplicationContext(),header.mFragment);
    startActivity(intent);
  }
}
 

Example 11

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: CallFeaturesSetting.java

  18 
vote

/** 
 * Simulates user clicking on a passed preference. Usually needed when the preference is a dialog preference and we want to invoke a dialog for this preference programmatically. TODO(iliat): figure out if there is a cleaner way to cause preference dlg to come up
 */
private void simulatePreferenceClick(Preference preference){
  final ListAdapter adapter=getPreferenceScreen().getRootAdapter();
  for (int idx=0; idx < adapter.getCount(); idx++) {
    if (adapter.getItem(idx) == preference) {
      getPreferenceScreen().onItemClick(this.getListView(),null,idx,adapter.getItemId(idx));
      break;
    }
  }
}
 

Example 12

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/preferences/.

Source file: PreferencesActivityHC.java

  18 
vote

@Override public void onResume(){
  super.onResume();
  ListAdapter listAdapter=getListAdapter();
  if (listAdapter instanceof HeaderAdapter) {
    ((HeaderAdapter)listAdapter).resume();
  }
}
 

Example 13

From project Backyard-Brains-Android-App, under directory /src/com/backyardbrains/.

Source file: FileListActivity.java

  18 
vote

void rescanFiles(){
  File[] files=bybDirectory.listFiles();
  if (files != null) {
    ListAdapter adapter=new FileListAdapter(this,R.layout.file_list_row_layout,files);
    setListAdapter(adapter);
  }
}
 

Example 14

From project Birthdays, under directory /src/com/rexmenpara/birthdays/.

Source file: BirthdaysActivity.java

  18 
vote

@Override public void handleMessage(Message msg){
  if (msg.arg1 == MESSAGE_DATA_LOAD) {
    ListAdapter adapter=new BirthdayArrayAdapter(ContextManager.getContext(),R.layout.view_list_item,(BirthdayBean[])msg.obj);
    setListAdapter(adapter);
  }
}
 

Example 15

From project BombusLime, under directory /src/org/bombusim/lime/fragments/.

Source file: RosterFragment.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setHasOptionsMenu(true);
  statusIcons=new Bitmap[]{BitmapFactory.decodeResource(getResources(),R.drawable.status_offline),BitmapFactory.decodeResource(getResources(),R.drawable.status_online),BitmapFactory.decodeResource(getResources(),R.drawable.status_chat),BitmapFactory.decodeResource(getResources(),R.drawable.status_away),BitmapFactory.decodeResource(getResources(),R.drawable.status_xa),BitmapFactory.decodeResource(getResources(),R.drawable.status_dnd),BitmapFactory.decodeResource(getResources(),R.drawable.status_ask),BitmapFactory.decodeResource(getResources(),R.drawable.status_unknown),BitmapFactory.decodeResource(getResources(),R.drawable.status_invisible)};
  ListAdapter adapter=new RosterAdapter(getActivity(),statusIcons);
  setListAdapter(adapter);
  sb=new XmppServiceBinding(getActivity());
  Lime.getInstance().saveBinding(sb);
}
 

Example 16

From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 17

From project creamed_glacier_app_settings, under directory /src/com/android/settings/.

Source file: Settings.java

  18 
vote

@Override public void onResume(){
  super.onResume();
  ListAdapter listAdapter=getListAdapter();
  if (listAdapter instanceof HeaderAdapter) {
    ((HeaderAdapter)listAdapter).resume();
  }
}
 

Example 18

From project cw-advandroid, under directory /ContentProvider/ConstantsPlus/src/com/commonsware/android/constants/.

Source file: ConstantsBrowser.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  constantsCursor=managedQuery(Provider.Constants.CONTENT_URI,PROJECTION,null,null,null);
  ListAdapter adapter=new SimpleCursorAdapter(this,R.layout.row,constantsCursor,new String[]{Provider.Constants.TITLE,Provider.Constants.VALUE},new int[]{R.id.title,R.id.value});
  setListAdapter(adapter);
  registerForContextMenu(getListView());
}
 

Example 19

From project cw-android, under directory /Database/Constants/src/com/commonsware/android/constants/.

Source file: ConstantsBrowser.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  db=new DatabaseHelper(this);
  constantsCursor=db.getReadableDatabase().rawQuery("SELECT _ID, title, value " + "FROM constants ORDER BY title",null);
  ListAdapter adapter=new SimpleCursorAdapter(this,R.layout.row,constantsCursor,new String[]{DatabaseHelper.TITLE,DatabaseHelper.VALUE},new int[]{R.id.title,R.id.value});
  setListAdapter(adapter);
  registerForContextMenu(getListView());
}
 

Example 20

From project cw-omnibus, under directory /ContentProvider/ConstantsPlus/src/com/commonsware/android/constants/.

Source file: ConstantsBrowser.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  constantsCursor=managedQuery(Provider.Constants.CONTENT_URI,PROJECTION,null,null,null);
  ListAdapter adapter=new SimpleCursorAdapter(this,R.layout.row,constantsCursor,new String[]{Provider.Constants.TITLE,Provider.Constants.VALUE},new int[]{R.id.title,R.id.value});
  setListAdapter(adapter);
  registerForContextMenu(getListView());
}
 

Example 21

From project DeskSMS, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 22

From project Diktofon, under directory /app/src/kaljurand_at_gmail_dot_com/diktofon/activity/.

Source file: RecordingListActivity.java

  18 
vote

/** 
 * Call this whenever the list of recordings changes.
 */
private void refreshAdapter(){
  ListAdapter adapter=mListView.getAdapter();
  if (adapter == null) {
    toast("ERROR: refreshAdapter() failed: mListView.getAdapter() == null");
  }
 else {
    RecordingListAdapter recordingListAdapter=(RecordingListAdapter)adapter;
    recordingListAdapter.setSearchQuery(mQuery);
    recordingListAdapter.refresh();
  }
}
 

Example 23

From project dmix, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 24

From project dreamDroid, under directory /libraries/ABS/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 25

From project droid-fu, under directory /src/main/java/com/github/droidfu/activities/.

Source file: BetterListActivity.java

  18 
vote

@Override protected void onSaveInstanceState(Bundle outState){
  super.onSaveInstanceState(outState);
  ListAdapter adapter=getListAdapter();
  if (adapter instanceof ListAdapterWithProgress<?>) {
    boolean isLoading=((ListAdapterWithProgress<?>)adapter).isLoadingData();
    outState.putBoolean(IS_BUSY_EXTRA,isLoading);
  }
}
 

Example 26

From project examples_2, under directory /SearchView/actionbarsherlock-lib/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 27

From project farebot, under directory /libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 28

From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 29

From project GnucashMobile, under directory /com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 30

From project Google-Tasks-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 31

From project HSR-Timetable, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 32

From project huiswerk, under directory /print/zxing-1.6/android/src/com/google/zxing/client/android/share/.

Source file: BookmarkPickerActivity.java

  18 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  cursor=getContentResolver().query(Browser.BOOKMARKS_URI,BOOKMARK_PROJECTION,BOOKMARK_SELECTION,null,null);
  startManagingCursor(cursor);
  ListAdapter adapter=new SimpleCursorAdapter(this,R.layout.bookmark_picker_list_item,cursor,BOOKMARK_PROJECTION,TWO_LINE_VIEW_IDS);
  setListAdapter(adapter);
}
 

Example 33

From project iosched_3, under directory /libprojects/abs/src/com/actionbarsherlock/internal/widget/.

Source file: IcsSpinner.java

  18 
vote

/** 
 * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, return true.
 */
public boolean areAllItemsEnabled(){
  final ListAdapter adapter=mListAdapter;
  if (adapter != null) {
    return adapter.areAllItemsEnabled();
  }
 else {
    return true;
  }
}
 

Example 34

From project android-client_2, under directory /src/org/mifos/androidclient/util/.

Source file: ListMeasuringUtils.java

  17 
vote

public static void setListViewHeightBasedOnChildren(ListView listView){
  ListAdapter listAdapter=listView.getAdapter();
  if (listAdapter == null) {
    return;
  }
  int totalHeight=0;
  int desiredWidth=View.MeasureSpec.makeMeasureSpec(listView.getWidth(),View.MeasureSpec.AT_MOST);
  for (int i=0; i < listAdapter.getCount(); i++) {
    View listItem=listAdapter.getView(i,null,listView);
    listItem.measure(desiredWidth,View.MeasureSpec.UNSPECIFIED);
    totalHeight+=listItem.getMeasuredHeight();
  }
  ViewGroup.LayoutParams params=listView.getLayoutParams();
  params.height=totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
  listView.setLayoutParams(params);
  listView.requestLayout();
}
 

Example 35

From project android-context, under directory /defunct/.

Source file: ContextBrowserActivity.java

  17 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  tts=new TextToSpeech(this,this);
  Intent intent=null;
  intent=new Intent(this.getApplicationContext(),edu.fsu.cs.contextprovider.sensor.GPSService.class);
  startService(intent);
  intent=new Intent(this.getApplicationContext(),edu.fsu.cs.contextprovider.sensor.NetworkService.class);
  startService(intent);
  intent=new Intent(this.getApplicationContext(),edu.fsu.cs.contextprovider.sensor.AccelerometerService.class);
  startService(intent);
  MovementMonitor.StartThread(5);
  Geocoder geocoder=new Geocoder(this,Locale.getDefault());
  LocationMonitor.StartThread(5,geocoder);
  intent=new Intent(this.getApplicationContext(),edu.fsu.cs.contextprovider.sensor.TelephonyService.class);
  startService(intent);
  contextCursor=managedQuery(ContextProvider.Cntxt.CONTENT_URI,PROJECTION,null,null,null);
  ListAdapter adapter=new SimpleCursorAdapter(this,R.layout.row,contextCursor,new String[]{ContextProvider.Cntxt.TITLE,ContextProvider.Cntxt.VALUE},new int[]{R.id.title,R.id.value});
  setListAdapter(adapter);
  registerForContextMenu(getListView());
}
 

Example 36

From project android-pulltorefresh, under directory /library/src/com/handmark/pulltorefresh/library/.

Source file: PullToRefreshListView.java

  17 
vote

@Override protected void resetHeader(){
  ListAdapter adapter=mRefreshableView.getAdapter();
  if (!getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
    super.resetHeader();
    return;
  }
  LoadingLayout originalLoadingLayout, listViewLoadingLayout;
  int scrollToHeight, selection;
  boolean scrollLvToEdge;
switch (getCurrentMode()) {
case PULL_UP_TO_REFRESH:
    originalLoadingLayout=getFooterLayout();
  listViewLoadingLayout=mFooterLoadingView;
selection=mRefreshableView.getCount() - 1;
scrollToHeight=getFooterHeight();
scrollLvToEdge=Math.abs(mRefreshableView.getLastVisiblePosition() - selection) <= 1;
break;
case PULL_DOWN_TO_REFRESH:
default :
originalLoadingLayout=getHeaderLayout();
listViewLoadingLayout=mHeaderLoadingView;
scrollToHeight=-getHeaderHeight();
selection=0;
scrollLvToEdge=Math.abs(mRefreshableView.getFirstVisiblePosition() - selection) <= 1;
break;
}
originalLoadingLayout.setVisibility(View.VISIBLE);
if (scrollLvToEdge && getState() != MANUAL_REFRESHING && listViewLoadingLayout.getVisibility() == View.VISIBLE) {
mRefreshableView.setSelection(selection);
setHeaderScroll(scrollToHeight);
}
listViewLoadingLayout.setVisibility(View.GONE);
super.resetHeader();
}
 

Example 37

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/list/activity/.

Source file: ContextsActivity.java

  17 
vote

@Override protected ListAdapter createListAdapter(Cursor cursor){
  ListAdapter adapter=new SimpleCursorAdapter(this,android.R.layout.simple_list_item_1,cursor,new String[]{ContextProvider.Contexts.NAME},new int[]{android.R.id.text1}){
    public View getView(    int position,    View convertView,    ViewGroup parent){
      Cursor cursor=(Cursor)getItem(position);
      Context context=getListConfig().getPersister().read(cursor);
      ContextView contextView;
      if (convertView instanceof ContextView) {
        contextView=(ContextView)convertView;
      }
 else {
        contextView=new ContextView(parent.getContext()){
          protected int getViewResourceId(){
            return R.layout.list_context_view;
          }
        }
;
      }
      contextView.setTaskCountArray(mTaskCountArray);
      contextView.updateView(context);
      return contextView;
    }
  }
;
  return adapter;
}
 

Example 38

From project androidquery, under directory /src/com/androidquery/util/.

Source file: Common.java

  17 
vote

private void onScrollStateChanged2(AbsListView lv,int scrollState){
  lv.setTag(AQuery.TAG_NUM,scrollState);
  if (scrollState == SCROLL_STATE_IDLE) {
    int first=lv.getFirstVisiblePosition();
    int last=lv.getLastVisiblePosition();
    int count=last - first;
    ListAdapter la=lv.getAdapter();
    for (int i=0; i <= count; i++) {
      long packed=i + first;
      View convertView=lv.getChildAt(i);
      Number targetPacked=(Number)convertView.getTag(AQuery.TAG_NUM);
      if (targetPacked != null) {
        la.getView((int)packed,convertView,lv);
        convertView.setTag(AQuery.TAG_NUM,null);
      }
 else {
      }
    }
  }
}
 

Example 39

From project andstatus, under directory /src/org/andstatus/app/account/.

Source file: AccountSelector.java

  17 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  MyPreferences.loadTheme(TAG,this);
  setContentView(R.layout.accountlist);
  ArrayList<Map<String,String>> data=new ArrayList<Map<String,String>>();
  for (int ind=0; ind < MyAccount.list().length; ind++) {
    HashMap<String,String> map=new HashMap<String,String>();
    map.put(KEY_NAME,MyAccount.list()[ind].getAccountGuid());
    map.put(KEY_TYPE,TYPE_ACCOUNT);
    data.add(map);
  }
  ListAdapter adapter=new SimpleAdapter(this,data,R.layout.accountlist_item,new String[]{KEY_NAME,KEY_TYPE},new int[]{R.id.name,R.id.type});
  setListAdapter(adapter);
  getListView().setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      String accountName=((TextView)view.findViewById(R.id.name)).getText().toString();
      MyAccount ma=MyAccount.getMyAccount(accountName);
      if (ma.isPersistent()) {
        ma.setCurrentMyAccount();
        AccountSelector.this.setResult(RESULT_OK);
        finish();
      }
    }
  }
);
}
 

Example 40

From project apps-for-android, under directory /WikiNotes/src/com/google/android/wikinotes/.

Source file: WikiNotesList.java

  17 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Intent intent=getIntent();
  Uri uri=null;
  String query=null;
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    query=intent.getStringExtra(SearchManager.QUERY);
  }
 else   if (savedInstanceState != null) {
    query=savedInstanceState.getString(SearchManager.QUERY);
  }
  if (query != null && query.length() > 0) {
    uri=Uri.withAppendedPath(WikiNote.Notes.SEARCH_URI,Uri.encode(query));
  }
  if (uri == null) {
    uri=WikiNote.Notes.ALL_NOTES_URI;
  }
  Cursor c=managedQuery(uri,PROJECTION,null,null,WikiNote.Notes.DEFAULT_SORT_ORDER);
  mCursor=c;
  mHelper=new WikiActivityHelper(this);
  ListAdapter adapter=new SimpleCursorAdapter(this,android.R.layout.simple_list_item_1,mCursor,new String[]{WikiNote.Notes.TITLE},new int[]{android.R.id.text1});
  setListAdapter(adapter);
  setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
}
 

Example 41

From project beintoo-android-sdk, under directory /BeintooSDK/src/com/beintoo/activities/marketplace/.

Source file: MarketplaceCoupon.java

  17 
vote

private void setListViewHeightBasedOnChildren(ListView listView){
  ListAdapter listAdapter=listView.getAdapter();
  if (listAdapter == null) {
    return;
  }
  int totalHeight=0;
  int desiredWidth=MeasureSpec.makeMeasureSpec(listView.getWidth(),MeasureSpec.UNSPECIFIED);
  for (int i=0; i < listAdapter.getCount(); i++) {
    View listItem=listAdapter.getView(i,null,listView);
    listItem.measure(desiredWidth,MeasureSpec.UNSPECIFIED);
    totalHeight+=listItem.getMeasuredHeight();
  }
  ViewGroup.LayoutParams params=listView.getLayoutParams();
  params.height=totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
  listView.setLayoutParams(params);
  listView.requestLayout();
}
 

Example 42

From project cow, under directory /libs/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsListPopupWindow.java

  17 
vote

private int measureHeightOfChildren(int widthMeasureSpec,int startPosition,int endPosition,final int maxHeight,int disallowPartialChildPosition){
  final ListAdapter adapter=mAdapter;
  if (adapter == null) {
    return mDropDownList.getTop() + mDropDownList.getBottom();
  }
  int returnedHeight=mDropDownList.getTop() + mDropDownList.getBottom();
  final int dividerHeight=((mDropDownList.getDividerHeight() > 0) && mDropDownList.getDivider() != null) ? mDropDownList.getDividerHeight() : 0;
  int prevHeightWithoutPartialChild=0;
  int i;
  View child;
  endPosition=(endPosition == -1) ? adapter.getCount() - 1 : endPosition;
  for (i=startPosition; i <= endPosition; ++i) {
    child=mAdapter.getView(i,null,mDropDownList);
    if (mDropDownList.getCacheColorHint() != 0) {
      child.setDrawingCacheBackgroundColor(mDropDownList.getCacheColorHint());
    }
    measureScrapChild(child,i,widthMeasureSpec);
    if (i > 0) {
      returnedHeight+=dividerHeight;
    }
    returnedHeight+=child.getMeasuredHeight();
    if (returnedHeight >= maxHeight) {
      return (disallowPartialChildPosition >= 0) && (i > disallowPartialChildPosition) && (prevHeightWithoutPartialChild > 0)&& (returnedHeight != maxHeight) ? prevHeightWithoutPartialChild : maxHeight;
    }
    if ((disallowPartialChildPosition >= 0) && (i >= disallowPartialChildPosition)) {
      prevHeightWithoutPartialChild=returnedHeight;
    }
  }
  return returnedHeight;
}
 

Example 43

From project friendica-for-android, under directory /libpulltorefresh/src/com/handmark/pulltorefresh/library/.

Source file: PullToRefreshListView.java

  17 
vote

@Override protected void resetHeader(){
  ListAdapter adapter=mRefreshableView.getAdapter();
  if (!getShowViewWhileRefreshing() || null == adapter || adapter.isEmpty()) {
    super.resetHeader();
    return;
  }
  LoadingLayout originalLoadingLayout;
  LoadingLayout listViewLoadingLayout;
  int scrollToHeight=getHeaderHeight();
  int selection;
  boolean scroll;
switch (getCurrentMode()) {
case PULL_UP_TO_REFRESH:
    originalLoadingLayout=getFooterLayout();
  listViewLoadingLayout=mFooterLoadingView;
selection=mRefreshableView.getCount() - 1;
scroll=mRefreshableView.getLastVisiblePosition() == selection;
break;
case PULL_DOWN_TO_REFRESH:
default :
originalLoadingLayout=getHeaderLayout();
listViewLoadingLayout=mHeaderLoadingView;
scrollToHeight*=-1;
selection=0;
scroll=mRefreshableView.getFirstVisiblePosition() == selection;
break;
}
originalLoadingLayout.setVisibility(View.VISIBLE);
if (scroll && getState() != MANUAL_REFRESHING) {
mRefreshableView.setSelection(selection);
setHeaderScroll(scrollToHeight);
}
listViewLoadingLayout.setVisibility(View.GONE);
super.resetHeader();
}
 

Example 44

From project gh4a, under directory /src/com/gh4a/.

Source file: SearchActivity.java

  17 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterView.AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
  ListAdapter listAdapter=null;
  if (mSearchByUser) {
    listAdapter=userAdapter;
  }
 else {
    listAdapter=repositoryAdapter;
  }
  Object object=(Object)listAdapter.getItem(info.position);
  String title=item.getTitle().toString();
  if (title.startsWith("User")) {
    Intent intent=new Intent().setClass(SearchActivity.this,UserActivity.class);
    String username=null;
    if (object instanceof SearchRepository) {
      SearchRepository repository=(SearchRepository)object;
      username=repository.getOwner();
    }
    if (mSearchByUser) {
      User user=(User)object;
      username=user.getLogin();
    }
    intent.putExtra(Constants.User.USER_LOGIN,username);
    startActivity(intent);
  }
 else   if (title.startsWith("Repo")) {
    SearchRepository repository=(SearchRepository)object;
    getApplicationContext().openRepositoryInfoActivity(this,repository.getOwner(),repository.getName(),0);
  }
  return true;
}
 

Example 45

From project Gibberbot, under directory /src/info/guardianproject/otr/app/im/app/.

Source file: BlockedContactsActivity.java

  17 
vote

private boolean resolveIntent(){
  Intent i=getIntent();
  Uri uri=i.getData();
  if (uri == null) {
    warning("No data to show");
    return false;
  }
  long accountId=ContentUris.parseId(uri);
  Uri accountUri=ContentUris.withAppendedId(Imps.Account.CONTENT_URI,accountId);
  Cursor accountCursor=getContentResolver().query(accountUri,null,null,null,null);
  if (accountCursor == null) {
    warning("Bad account");
    return false;
  }
  if (!accountCursor.moveToFirst()) {
    warning("Bad account");
    accountCursor.close();
    return false;
  }
  long providerId=accountCursor.getLong(accountCursor.getColumnIndexOrThrow(Imps.Account.PROVIDER));
  String username=accountCursor.getString(accountCursor.getColumnIndexOrThrow(Imps.Account.USERNAME));
  BrandingResources brandingRes=mApp.getBrandingResource(providerId);
  getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON,brandingRes.getDrawable(BrandingResourceIDs.DRAWABLE_LOGO));
  setTitle(getResources().getString(R.string.blocked_list_title,username));
  accountCursor.close();
  Cursor c=managedQuery(uri,PROJECTION,null,null,Imps.BlockedList.DEFAULT_SORT_ORDER);
  if (c == null) {
    warning("Database error when query " + uri);
    return false;
  }
  ListAdapter adapter=new BlockedContactsAdapter(c,this);
  setListAdapter(adapter);
  return true;
}
 

Example 46

From project IRC-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsListPopupWindow.java

  17 
vote

private int measureHeightOfChildren(int widthMeasureSpec,int startPosition,int endPosition,final int maxHeight,int disallowPartialChildPosition){
  final ListAdapter adapter=mAdapter;
  if (adapter == null) {
    return mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
  }
  int returnedHeight=mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
  final int dividerHeight=((mDropDownList.getDividerHeight() > 0) && mDropDownList.getDivider() != null) ? mDropDownList.getDividerHeight() : 0;
  int prevHeightWithoutPartialChild=0;
  int i;
  View child;
  endPosition=(endPosition == -1) ? adapter.getCount() - 1 : endPosition;
  for (i=startPosition; i <= endPosition; ++i) {
    child=mAdapter.getView(i,null,mDropDownList);
    if (mDropDownList.getCacheColorHint() != 0) {
      child.setDrawingCacheBackgroundColor(mDropDownList.getCacheColorHint());
    }
    measureScrapChild(child,i,widthMeasureSpec);
    if (i > 0) {
      returnedHeight+=dividerHeight;
    }
    returnedHeight+=child.getMeasuredHeight();
    if (returnedHeight >= maxHeight) {
      return (disallowPartialChildPosition >= 0) && (i > disallowPartialChildPosition) && (prevHeightWithoutPartialChild > 0)&& (returnedHeight != maxHeight) ? prevHeightWithoutPartialChild : maxHeight;
    }
    if ((disallowPartialChildPosition >= 0) && (i >= disallowPartialChildPosition)) {
      prevHeightWithoutPartialChild=returnedHeight;
    }
  }
  return returnedHeight;
}
 

Example 47

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: ListLoadingFragment.java

  15 
vote

public void setListAdapter(ListAdapter adapter){
  if (!shouldAnimateShowingList()) {
    setListShownNoAnimation(true);
  }
  super.setListAdapter(adapter);
}
 

Example 48

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/cwac/adapter/.

Source file: AdapterWrapper.java

  15 
vote

/** 
 * Constructor wrapping a supplied ListAdapter
 */
public AdapterWrapper(ListAdapter wrapped){
  super();
  this.wrapped=wrapped;
  wrapped.registerDataSetObserver(new DataSetObserver(){
    public void onChanged(){
      notifyDataSetChanged();
    }
    public void onInvalidated(){
      notifyDataSetInvalidated();
    }
  }
);
}
 

Example 49

From project android-joedayz, under directory /Proyectos/GreenDroid/src/greendroid/app/.

Source file: GDListActivity.java

  15 
vote

/** 
 * Provides the Adapter for the ListView handled by this {@link GDListActivity}
 * @param adapter The ListAdapter to set.
 */
public void setListAdapter(ListAdapter adapter){
synchronized (this) {
    ensureLayout();
    mAdapter=adapter;
    mListView.setAdapter(adapter);
  }
}
 

Example 50

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/controller/.

Source file: FileListController.java

  15 
vote

/** 
 * Provide the cursor for the list view.
 */
public void setListAdapter(ListAdapter adapter){
synchronized (this) {
    mAdapter=adapter;
    mList.setAdapter(adapter);
  }
}
 

Example 51

From project android_packages_apps_QuickSearchBox, under directory /src/com/android/quicksearchbox/.

Source file: SearchWidgetConfigActivity.java

  15 
vote

@Override public void setAdapter(ListAdapter adapter){
  if (adapter == mAdapter)   return;
  if (mAdapter != null)   mAdapter.close();
  mAdapter=(CorporaAdapter)adapter;
  super.setAdapter(adapter);
}
 

Example 52

From project CineShowTime-Android, under directory /Libraries/GreenDroid/src/greendroid/app/.

Source file: GDListActivity.java

  15 
vote

/** 
 * Provides the Adapter for the ListView handled by this {@link GDListActivity}
 * @param adapter The {@link ListAdapter} to set.
 */
public void setListAdapter(ListAdapter adapter){
synchronized (this) {
    ensureLayout();
    mAdapter=adapter;
    mListView.setAdapter(adapter);
  }
}
 

Example 53

From project droidkit, under directory /src/org/droidkit/widget/.

Source file: HandyListView.java

  15 
vote

@Override public void setAdapter(ListAdapter adapter){
  if (mLoadingListView != null)   mLoadingListView.setVisibility(View.GONE);
  setVisibility(View.VISIBLE);
  super.setEmptyView(mEmptyListView);
  mEmptyListView=null;
  super.setAdapter(adapter);
}
 

Example 54

From project eoit, under directory /EOIT/src/fr/eoit/activity/util/.

Source file: AmazingListView.java

  15 
vote

@Override public void setAdapter(ListAdapter adapter){
  if (!(adapter instanceof AmazingSimpleCursorAdapter)) {
    throw new IllegalArgumentException(AmazingListView.class.getSimpleName() + " must use adapter of type " + AmazingSimpleCursorAdapter.class.getSimpleName());
  }
  if (this.adapter != null) {
    this.adapter.setHasMorePagesListener(null);
    this.setOnScrollListener(null);
  }
  this.adapter=(AmazingSimpleCursorAdapter)adapter;
  ((AmazingSimpleCursorAdapter)adapter).setHasMorePagesListener(this);
  this.setOnScrollListener((AmazingSimpleCursorAdapter)adapter);
  View dummy=new View(getContext());
  super.addFooterView(dummy);
  super.setAdapter(adapter);
  super.removeFooterView(dummy);
}
 

Example 55

From project evodroid, under directory /src/com/commonsware/cwac/thumbnail/.

Source file: ThumbnailAdapter.java

  15 
vote

/** 
 * Constructor wrapping a supplied ListAdapter
 */
public ThumbnailAdapter(Activity host,ListAdapter wrapped,SimpleWebImageCache<ThumbnailBus,ThumbnailMessage> cache,int[] imageIds){
  super(wrapped);
  this.host=host;
  this.imageIds=imageIds;
  this.cache=cache;
  cache.getBus().register(getBusKey(),onCache);
}
 

Example 56

From project fanfoudroid, under directory /src/com/commonsware/cwac/merge/.

Source file: MergeAdapter.java

  15 
vote

/** 
 * Get the data item associated with the specified position in the data set.
 * @param position Position of the item whose data we want
 */
@Override public Object getItem(int position){
  for (  ListAdapter piece : pieces) {
    int size=piece.getCount();
    if (position < size) {
      return (piece.getItem(position));
    }
    position-=size;
  }
  return (null);
}
 

Example 57

From project GreenDroid, under directory /GreenDroid/src/greendroid/app/.

Source file: GDListActivity.java

  15 
vote

/** 
 * Provides the Adapter for the ListView handled by this {@link GDListActivity}
 * @param adapter The ListAdapter to set.
 */
public void setListAdapter(ListAdapter adapter){
synchronized (this) {
    ensureLayout();
    mAdapter=adapter;
    mListView.setAdapter(adapter);
  }
}
 

Example 58

From project GreenDroidQABar, under directory /src/greendroid/app/.

Source file: GDListActivity.java

  15 
vote

/** 
 * Provides the Adapter for the ListView handled by this {@link GDListActivity}
 * @param adapter The {@link ListAdapter} to set.
 */
public void setListAdapter(ListAdapter adapter){
synchronized (this) {
    ensureLayout();
    mAdapter=adapter;
    mListView.setAdapter(adapter);
  }
}
 

Example 59

From project iPhoroidUI, under directory /src/org/klab/iphoroid/widget/listview/.

Source file: AdapterWrapper.java

  15 
vote

/** 
 * Constructor wrapping a supplied ListAdapter
 */
public AdapterWrapper(ListAdapter wrapped){
  super();
  this.wrapped=wrapped;
  wrapped.registerDataSetObserver(new DataSetObserver(){
    public void onChanged(){
      notifyDataSetChanged();
    }
    public void onInvalidated(){
      notifyDataSetInvalidated();
    }
  }
);
}