当前位置: 首页>>代码示例>>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;未经允许,请勿转载。