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


Java ArrayAdapter類代碼示例

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


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

示例1: initPowerRankings

import android.widget.ArrayAdapter; //導入依賴的package包/類
private void initPowerRankings(List<Profile> profiles){

        powerList = (ListView)findViewById(R.id.rankingsPowerList);

        List<String> elements = new ArrayList<>();
        // compare based on points, in descending order
        Collections.sort(profiles, new Comparator<Profile>() {
            @Override
            public int compare(Profile p1, Profile p2) {
                Integer lhsPoints = p1.getPowerPoints();
                Integer rhsPoints = p2.getPowerPoints();
                return -1 * lhsPoints.compareTo(rhsPoints);
            }
        });

        int rank = 1;
        for (Profile profile : profiles){
            int points = profile.getPowerPoints();
            elements.add(rank + ":      " + profile.getName() + ": " + points);
            ++rank;
        }

        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.list_item, elements);
        powerList.setAdapter(adapter);
    }
 
開發者ID:CMPUT301F17T15,項目名稱:CIA,代碼行數:26,代碼來源:RankingsActivity.java

示例2: initOverallRankings

import android.widget.ArrayAdapter; //導入依賴的package包/類
private void initOverallRankings(List<Profile> profiles){

        overallList = (ListView)findViewById(R.id.rankingsList);
        List<String> elements = new ArrayList<>();
        // compare based on points, in descending order
        Collections.sort(profiles, new Comparator<Profile>() {
            @Override
            public int compare(Profile p1, Profile p2) {
                Integer lhsPoints = p1.getHabitPoints();
                Integer rhsPoints = p2.getHabitPoints();
                return -1 * lhsPoints.compareTo(rhsPoints);
            }
        });

        int rank = 1;
        for (Profile profile : profiles){
            int points = profile.getHabitPoints();
            elements.add(rank + ":      " + profile.getName() + ": " + points);
            ++rank;
        }

        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.list_item, elements);
        overallList.setAdapter(adapter);

    }
 
開發者ID:CMPUT301F17T15,項目名稱:CIA,代碼行數:26,代碼來源:RankingsActivity.java

示例3: onCreateView

import android.widget.ArrayAdapter; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    String forecastArray[] = {};
    FetchWeatherTask weatherTask = new FetchWeatherTask();
    weatherTask.execute();
    List<String> weekForecast = new ArrayList(Arrays.asList(forecastArray));
    mForeCastAdapter = new ArrayAdapter<String>(
            getActivity(),
            R.layout.list_item_forecast,
            R.id.list_item_forecast_textview,
            weekForecast);
    ListView listview = (ListView) rootView.findViewById(R.id.listview_forecast);
    listview.setAdapter(mForeCastAdapter);
    return rootView;
}
 
開發者ID:NullPointersInc,項目名稱:Bella-Android,代碼行數:18,代碼來源:ForecastFragment.java

示例4: initSpecificControls

import android.widget.ArrayAdapter; //導入依賴的package包/類
protected void initSpecificControls() {
    initSpnUomFuel();

    //setup bpartner adapter
    mBPartnerAdapter = null;
    if (getActivity() != null) {
        String[] entries = mDbAdapter.getAutoCompleteText(DBAdapter.TABLE_NAME_BPARTNER, null,
                "WHERE " + DB.COL_NAME_GEN_ISACTIVE + " = 'Y' " +
                        " AND LENGTH(TRIM(" + DB.COL_NAME_GEN_NAME + ")) > 0 " +
                        " AND " + DB.COL_NAME_BPARTNER__ISGASSTATION + " = 'Y'", 0, 0);
        if (entries != null) {
            mBPartnerAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, entries);
        }
        acBPartner.setAdapter(mBPartnerAdapter);
    }
}
 
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:17,代碼來源:RefuelEditFragment.java

示例5: initListPop

import android.widget.ArrayAdapter; //導入依賴的package包/類
public void initListPop() {
    listPopupWindow = new ListPopupWindow(getContext());
    ArrayAdapter arrayAdapter = new ArrayAdapter(getContext(), R.layout.item_list_pop, cardTemplateList);
    listPopupWindow.setAdapter(arrayAdapter);
    listPopupWindow.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    listPopupWindow.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);
    listPopupWindow.setAnchorView(mCardTemplate);
    listPopupWindow.setModal(true);
    listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mCardTemplate.setText(cardTemplateList.get(position));
            if ("2".equals(sparseArray.get(position).key)) {//虛擬卡
                setEnabledStatus(false);
            } else {
                setEnabledStatus(true);
            }
            cardTemplateId = sparseArray.get(position).key;
            listPopupWindow.dismiss();
        }
    });
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:23,代碼來源:SelectCardTypeFragment.java

示例6: updateAyahSpinner

import android.widget.ArrayAdapter; //導入依賴的package包/類
private void updateAyahSpinner(QuranSpinner spinner,
                               ArrayAdapter<CharSequence> adapter,
                               int maxAyah, int currentAyah) {
  final Context context = getActivity();
  if (context != null) {
    CharSequence[] ayahs = new String[maxAyah];
    for (int i = 0; i < maxAyah; i++) {
      ayahs[i] = QuranUtils.getLocalizedNumber(context, (i + 1));
    }
    adapter.clear();

    for (int i = 0; i < maxAyah; i++) {
      adapter.add(ayahs[i]);
    }
    spinner.setSelection(currentAyah - 1);
  }
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:18,代碼來源:AyahPlaybackFragment.java

示例7: onCreate

import android.widget.ArrayAdapter; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {  
	super.onCreate(savedInstanceState);  
	setContentView(R.layout.item_dialog); 
	setCanceledOnTouchOutside(true);

	tvItemDialogTitle = (TextView) findViewById(R.id.tvItemDialogTitle);
	lvItemDialog = (ListView) findViewById(R.id.lvItemDialog);

	tvItemDialogTitle.setVisibility(StringUtil.isNotEmpty(title, true) ? View.VISIBLE : View.GONE);
	tvItemDialogTitle.setText("" + StringUtil.getCurrentString());
	
	adapter = new ArrayAdapter<String>(context, R.layout.item_dialog_item, items);
	lvItemDialog.setAdapter(adapter);
	lvItemDialog.setOnItemClickListener(this);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:ItemDialog.java

示例8: onCreate

import android.widget.ArrayAdapter; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_division);

    Bundle dataBundle = getIntent().getExtras();
    Data data = (Data) dataBundle.getSerializable("data");
    String div_name = dataBundle.getString("div");

    bg = (ImageView) findViewById(R.id.division_image);
    placeList = (ListView) findViewById(R.id.place_list);
    divisionName = (TextView) findViewById(R.id.division_name);
    divisionName.setText(data.getDivisionName(div_name));

    bg.setImageResource(data.getImageRes(div_name));
    System.out.println(data.getPlaces(div_name));
    ArrayAdapter<String> adapter = new ArrayAdapter<String> (DivisionActivity.this, android.R.layout.simple_list_item_1,  data.getPlaces(div_name));
    placeList.setAdapter(adapter);

}
 
開發者ID:mehedi-shafi,項目名稱:Wireless-Programming-Works,代碼行數:21,代碼來源:DivisionActivity.java

示例9: displayListViewDialog

import android.widget.ArrayAdapter; //導入依賴的package包/類
private static void displayListViewDialog(@NonNull Context context, @NonNull String title, @NonNull ArrayList<String> list) {
    final android.app.Dialog dialog = new android.app.Dialog(context);

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_listview);

    TextView titleView = dialog.findViewById(R.id.dialog_title_text_view);
    titleView.setText(title);

    com.rey.material.widget.Button closeButton = dialog.findViewById(R.id.dialog_button_close);
    closeButton.setOnClickListener(v -> dialog.dismiss());

    ListView listView = dialog.findViewById(R.id.dialog_list_view);
    listView.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_dropdown_item_1line, list));

    dialog.setCancelable(true);
    dialog.show();

    Window window = dialog.getWindow();
    if (window != null) {
        window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    }
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:24,代碼來源:MapContentBuilder.java

示例10: 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

示例11: onCreate

import android.widget.ArrayAdapter; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  ListView listView = (ListView) findViewById(R.id.list);
  listView.setOnItemClickListener(this);

  ArrayAdapter<String> demoAdapter = new ArrayAdapter<String>(this,
      android.R.layout.simple_list_item_1);

  for (Demo demo : Demo.values()) {
    demoAdapter.add(getString(demo.titleResId));
  }

  listView.setAdapter(demoAdapter);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:MainActivity.java

示例12: onCreate

import android.widget.ArrayAdapter; //導入依賴的package包/類
/**
 * @see {@link Activity#onCreate}
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_open_api_base_layout);
    
    // 獲取功能列表
    mFuncList = getResources().getStringArray(R.array.statuses_func_list);
    // 初始化功能列表 ListView
    mFuncListView = (ListView)findViewById(R.id.api_func_list);
    mFuncListView.setAdapter(new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_1, mFuncList));
    mFuncListView.setOnItemClickListener(this);
    
    // 獲取當前已保存過的 Token
    mAccessToken = AccessTokenKeeper.readAccessToken(this);
    // 對statusAPI實例化
    mStatusesAPI = new StatusesAPI(this, Constants.APP_KEY, mAccessToken);
}
 
開發者ID:ligongzai,項目名稱:QianXun,代碼行數:22,代碼來源:WBStatusAPIActivity.java

示例13: BitmapAnimationCacheSelectorConfigurator

import android.widget.ArrayAdapter; //導入依賴的package包/類
public BitmapAnimationCacheSelectorConfigurator(
    Spinner spinner,
    BitmapFrameCacheChangedListener bitmapFrameCacheChangedListener,
    BitmapFrameCache.FrameCacheListener frameCacheListener) {
  mSpinner = spinner;
  mBitmapFrameCacheChangedListener = bitmapFrameCacheChangedListener;
  mFrameCacheListener = frameCacheListener;

  mContext = mSpinner.getContext();
  mArrayAdapter = new ArrayAdapter<>(spinner.getContext(), android.R.layout.simple_spinner_item);
  mArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  mSpinner.setAdapter(mArrayAdapter);

  addSampleBackends();
  setupSelector();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:BitmapAnimationCacheSelectorConfigurator.java

示例14: loadData

import android.widget.ArrayAdapter; //導入依賴的package包/類
/**
 * Load voice settings from file and set radio buttons
 * @throws IOException
 * @throws XmlPullParserException
 */
private void loadData() throws IOException, XmlPullParserException {
    ArrayMap<String, String> values = settingsManager.getSettings();
    voice = values.get("id");
    Voice loadedVoice = searchVoice(voice);
    if(loadedVoice == null){
        Toast.makeText(getContext(), "Errore caricamento impostazioni", Toast.LENGTH_SHORT).show();
        return;
    }
    // Language/Locale
    language = loadedVoice.get("locale");
    spnLanguage.setSelection(((ArrayAdapter) spnLanguage.getAdapter()).getPosition(language));
    // Gender
    gender = loadedVoice.get("gender");
    if(gender.equals("male"))
        rbM.setChecked(true);
    else
        rbF.setChecked(true);
    updateChoice();
    // Voice
    int pos=((ArrayAdapter) spnVoice.getAdapter()).getPosition(voice);
    spnVoice.setSelection(pos);
    // Speed
    speed = Float.valueOf(values.get("speed"));
    spnSpeed.setSelection(Math.round((speed - 1) / 0.25f));
}
 
開發者ID:Visions-Team,項目名稱:eBread,代碼行數:31,代碼來源:SettingTTSFragment.java

示例15: onCreate

import android.widget.ArrayAdapter; //導入依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_found_view);

        final TextView found_view_back = (TextView) findViewById(R.id.found_view_back);
        final ListView found_view_list = (ListView) findViewById(R.id.found_view_list);
//        Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out);

        ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, displayFoundItem());
        found_view_list.setAdapter(adapter);
        final Animation fade_in_anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_in);
        found_view_list.setAnimation(fade_in_anim);
        found_view_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                goToMain();
            }
        });
    }
 
開發者ID:IvoryCandy,項目名稱:Plus1s,代碼行數:21,代碼來源:FoundViewActivity.java


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