當前位置: 首頁>>代碼示例>>Java>>正文


Java ArrayAdapter.getCount方法代碼示例

本文整理匯總了Java中android.widget.ArrayAdapter.getCount方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayAdapter.getCount方法的具體用法?Java ArrayAdapter.getCount怎麽用?Java ArrayAdapter.getCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ArrayAdapter的用法示例。


在下文中一共展示了ArrayAdapter.getCount方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onTouch

import android.widget.ArrayAdapter; //導入方法依賴的package包/類
@Override
public boolean onTouch(View v, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        ArrayAdapter adapter = (ArrayAdapter) getAdapter();

        if (null != adapter) {

            if (_items.size() == 0) {
                for (int i = 0; i < adapter.getCount(); i++) {
                    _items.add(adapter.getItem(i));
                }
            }
            SearchableListDialog searchableListDialog = SearchableListDialog.newInstance
                    (_items);
            searchableListDialog.setOnSearchableItemClickListener(this);
            searchableListDialog.show(((Activity) _context).getFragmentManager(), "TAG");
        }
    }
    return true;
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:21,代碼來源:SearchableSpinner.java

示例2: selectSpinnerItemByValue

import android.widget.ArrayAdapter; //導入方法依賴的package包/類
/**
 *
 * @param spnr
 * @param value
 *
 * solution based on an answer from stack overflow
 * resource: https://stackoverflow.com/questions/11072576/set-selected-item-of-spinner-programmatically
 *
 */

public static void selectSpinnerItemByValue(Spinner spnr, String value) {
    ArrayAdapter<String> adapter = (ArrayAdapter<String>) spnr.getAdapter();
    String currentItem;

    for (int i = 0; i < adapter.getCount(); i++) {
        currentItem = adapter.getItem(i);
        if(currentItem.equals(value)) {
            spnr.setSelection(i);
            return;
        }
    }
}
 
開發者ID:CMPUT301F17T15,項目名稱:CIA,代碼行數:23,代碼來源:HabitViewActivity.java

示例3: isSameCollection

import android.widget.ArrayAdapter; //導入方法依賴的package包/類
public boolean isSameCollection(ArrayAdapter<TGSelectableItem> c1, ArrayAdapter<TGSelectableItem> c2) {
	if( c1 == c2 ) {
		return true;
	}
	if( c1 != null && c2 != null && c1.getCount() == c2.getCount() ) {
		int count = c1.getCount();
		for(int i = 0 ; i < count ; i ++) {
			if(!this.isSameObject(c1.getItem(i), c2.getItem(i))) {
				return false;
			}
		}
		return true;
	}
	return false;
}
 
開發者ID:axlecho,項目名稱:tuxguitar,代碼行數:16,代碼來源:TGBrowserView.java

示例4: initBLEMeters

import android.widget.ArrayAdapter; //導入方法依賴的package包/類
private int initBLEMeters() {
		int adapterCount = 0;
		if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
			 
		    mPairedMeterNames = new HashMap<String, String>();
		    mPairedMeterAddrs = new HashMap<String, String>();
	    mPairedMeterCount = MeterPreferenceDialog.getPairedMeters(this, mPairedMeterNames, mPairedMeterAddrs);
	    
	    ArrayAdapter<String> selectedMeterSpinnerAdapter = (ArrayAdapter<String>)mSelectedMeter.getAdapter();
	    adapterCount = selectedMeterSpinnerAdapter.getCount();
			String nameKey;
		String addrKey;
		String nameValue;
		String addrValue;
	    for (int i=0; i<mPairedMeterCount; i++) {
	    	nameKey = PCLinkLibraryDemoConstant.BLE_PAIRED_METER_NAME_ + String.valueOf(i);
			addrKey = PCLinkLibraryDemoConstant.BLE_PAIRED_METER_ADDR_ + String.valueOf(i);
			nameValue = mPairedMeterNames.get(nameKey);
			addrValue = mPairedMeterAddrs.get(addrKey);
		    String remoteDeviceName = nameValue + "/" + addrValue;
		    
		    if (selectedMeterSpinnerAdapter != null) {
		    	boolean find_flag = false;
			    for (int j=0; j<selectedMeterSpinnerAdapter.getCount(); j++) {
	 				String remoteDeviceName2 = selectedMeterSpinnerAdapter.getItem(j);
	 				if (remoteDeviceName.equals(remoteDeviceName2)) {
	 					find_flag = true;
	 					break;
	 				}
	 			}
			    if (!find_flag) {
				    adapterCount++;
 					selectedMeterSpinnerAdapter.add(remoteDeviceName);
			    }
		    }
	    }
	}
		
		return adapterCount;
}
 
開發者ID:Welloculus,項目名稱:MobileAppForPatient,代碼行數:41,代碼來源:PCLinkLibraryDemoActivity.java

示例5: setSpinnerSelectedID

import android.widget.ArrayAdapter; //導入方法依賴的package包/類
@SuppressWarnings("ConstantConditions")
public void setSpinnerSelectedID(Spinner sp, String text) {
    ArrayAdapter sca = (ArrayAdapter) sp.getAdapter();
    if (sca == null) {
        return;
    }

    for (int i = 0; i < sca.getCount(); i++) {
        if (sca.getItem(i) != null && sca.getItem(i).toString().equals(text)) {
            sp.setSelection(i);
            return;
        }
    }
}
 
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:15,代碼來源:BaseEditFragment.java


注:本文中的android.widget.ArrayAdapter.getCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。