本文整理汇总了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;
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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;
}
}
}