Java Code Examples for android.widget.ArrayAdapter

The following are top voted examples for showing how to use android.widget.ArrayAdapter. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CIA   File: RankingsActivity.java   View source code 6 votes vote down vote up
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);
    }
 
Example 2
Project: CIA   File: RankingsActivity.java   View source code 6 votes vote down vote up
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);

    }
 
Example 3
Project: Bella-Android   File: ForecastFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 4
Project: AndiCar   File: RefuelEditFragment.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 5
Project: CXJPadProject   File: SelectCardTypeFragment.java   View source code 6 votes vote down vote up
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();
        }
    });
}
 
Example 6
Project: Quran   File: AyahPlaybackFragment.java   View source code 6 votes vote down vote up
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);
  }
}
 
Example 7
Project: GitHub   File: ItemDialog.java   View source code 6 votes vote down vote up
@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);
}
 
Example 8
Project: Wireless-Programming-Works   File: DivisionActivity.java   View source code 6 votes vote down vote up
@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);

}
 
Example 9
Project: LucaHome-AndroidApplication   File: MapContentBuilder.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 10
Project: XERUNG   File: SearchableSpinner.java   View source code 6 votes vote down vote up
@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;
}
 
Example 11
Project: GitHub   File: MainActivity.java   View source code 6 votes vote down vote up
@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);
}
 
Example 12
Project: QianXun   File: WBStatusAPIActivity.java   View source code 6 votes vote down vote up
/**
 * @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);
}
 
Example 13
Project: GitHub   File: BitmapAnimationCacheSelectorConfigurator.java   View source code 6 votes vote down vote up
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();
}
 
Example 14
Project: eBread   File: SettingTTSFragment.java   View source code 6 votes vote down vote up
/**
 * 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));
}
 
Example 15
Project: Plus1s   File: FoundViewActivity.java   View source code 6 votes vote down vote up
@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();
            }
        });
    }
 
Example 16
Project: AndroidNewArchitectureExample   File: CityListFragment.java   View source code 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    viewModel = ViewModelProviders.of(getActivity()).get(MainActivityViewModel.class);
    viewModel.listOfCities().observe(this, cities -> {
        if (cities == null)
            cities = Collections.emptyList();
        ArrayAdapter<String> adapter = new ArrayAdapter<>(this.getContext(), android.R.layout.simple_list_item_1, cities);
        cityList.setAdapter(adapter);
    });

    cityList.setOnItemClickListener((parent, view, position, id) -> {
        String cityName = (String) parent.getItemAtPosition(position);
        viewModel.selectCity(cityName);
    });
}
 
Example 17
Project: Aurora   File: SwitchVideoTypeDialog.java   View source code 6 votes vote down vote up
public void initList(List<SwitchVideoModel> data, OnListItemClickListener onItemClickListener) {
    this.onItemClickListener = onItemClickListener;
    this.data = data;

    LayoutInflater inflater = LayoutInflater.from(mContext);
    View view = inflater.inflate(R.layout.switch_video_dialog, null);
    listView = (ListView) view.findViewById(R.id.switch_dialog_list);
    setContentView(view);
    adapter = new ArrayAdapter<>(mContext, R.layout.switch_video_dialog_item, data);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener());

    Window dialogWindow = getWindow();
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    DisplayMetrics d = mContext.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
    lp.width = (int) (d.widthPixels * 0.8); // 高度设置为屏幕的0.6
    dialogWindow.setAttributes(lp);
}
 
Example 18
Project: tuxguitar   File: TGBrowserView.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void refreshCollections() {
	ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(findActivity(), R.layout.view_browser_spinner_item, createCollectionValues());
	arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	
	TGSelectableItem selectedItem = new TGSelectableItem(findCurrentCollection(), null);
	Integer selectedItemPosition = arrayAdapter.getPosition(selectedItem);
	
	Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
	OnItemSelectedListener listener = spinner.getOnItemSelectedListener();
	spinner.setOnItemSelectedListener(null);
	if(!this.isSameCollection(arrayAdapter, (ArrayAdapter<TGSelectableItem>) spinner.getAdapter())) {
		spinner.setAdapter(arrayAdapter);
	}
	if( spinner.getSelectedItemPosition() != selectedItemPosition ) {
		spinner.setSelection(selectedItemPosition, false);
	}
	spinner.setOnItemSelectedListener(listener);
}
 
Example 19
Project: AndiCar   File: BackupListActivity.java   View source code 6 votes vote down vote up
private void fillBkList() {
        bkFileList = FileUtils.listBkFiles(this, false);
        if (bkFileList == null || bkFileList.isEmpty()) {
//            btnRestore.setEnabled(false);
            lvBackupList.setAdapter(null);
            return;
        }

        ArrayAdapter<String> listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_single_choice, bkFileList);
        lvBackupList.setAdapter(listAdapter);
        lvBackupList.setItemsCanFocus(false);
        lvBackupList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        lvBackupList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                selectedFile = bkFileList.get(i);

                //show the delete option
                mAppMenu.setGroupVisible(R.id.mnu_backup_list, true);
            }
        });
    }
 
Example 20
Project: project-weather   File: ChooseAreaFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.choose_area, container, false);
    // 设置系统状态栏高度
    View statusBar = view.findViewById(R.id.status_bar);
    ViewGroup.LayoutParams layoutParams = statusBar.getLayoutParams();
    layoutParams.height = getStatusBarHeight();
    if (getActivity() instanceof MainActivity) {
        statusBar.setVisibility(View.GONE);
    } else {
        statusBar.setVisibility(View.VISIBLE);
    }

    titleText = (TextView) view.findViewById(R.id.title_text);
    backButton = (Button) view.findViewById(R.id.back_button);
    listView = (ListView) view.findViewById(R.id.list_view);
    adapter = new ArrayAdapter<>(getContext(),
            android.R.layout.simple_list_item_1, dataList);
    listView.setAdapter(adapter);
    return view;
}
 
Example 21
Project: SkinFramework   File: SkinFragment.java   View source code 6 votes vote down vote up
void initAdapter(List<String> skins) {
    final Context context = mListView.getContext();
    mAdapter = new ArrayAdapter<String>(context, -1, skins) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = SkinManager.getInstance().getResources().getView(context, R.layout.item);
            }
            TextView tv = (TextView) convertView.findViewById(R.id.id_tv_title);
            String path = getItem(position);
            tv.setText(new File(path).getName());
            return convertView;
        }
    };
    mListView.setAdapter(mAdapter);
}
 
Example 22
Project: weather-mvp   File: ChooseAreaActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_choose_area);
    backButton = (Button) findViewById(R.id.back_button);
    areaName = (TextView) findViewById(R.id.area_name);
    listView = (ListView) findViewById(R.id.list_view);
    progressBar = (ProgressBar) findViewById(R.id.progress_bar);

    mAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_list_item_1, dataList);
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(this);
    backButton.setOnClickListener(this);
    showProvinceList();
}
 
Example 23
Project: CycleViewPager   File: WorkInListViewActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listview);

    mAutoScrollPagerAdapter = new BannerAdapter(this, 3, true);
    mListView = (ListView) findViewById(R.id.listview);
    mSwipeRefreshLayout = (CustomSwipeRefreshLayout) findViewById(R.id.swiperefresh_layout);
    // AutoScrollViewPager header
    View headerView = LayoutInflater.from(this).inflate(R.layout.list_header, mListView, false);
    mAutoScrollViewPager = (CycleViewPager) headerView.findViewById(R.id.banner);
    mIndicator = (ViewPagerIndicator) headerView.findViewById(R.id.viewpager_indicator);
    mListView.addHeaderView(headerView);
    // mAutoScrollViewPager.setPageSwitchDuration(800);
    // mAutoScrollViewPager.setAutoScrollInterval(4000);
    mListView.setAdapter(new ArrayAdapter<String>(WorkInListViewActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, getData()));
    mAutoScrollViewPager.setAdapter(mAutoScrollPagerAdapter);
    mIndicator.bindToViewPager(mAutoScrollViewPager);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            WorkInListViewActivity.this.onRefresh();
        }
    });
}
 
Example 24
Project: HtmlNative   File: ExampleListActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {
        mAssetFileList = filterHtmlFile(AssetsUtils.allFiles(this)).toArray();
        ListView listView = new ListView(this);
        ArrayAdapter<Object> arrayAdapter = new ArrayAdapter<>(this, R.layout
                .example_list_item, R.id.example_list_title, mAssetFileList);
        listView.setAdapter(arrayAdapter);
        listView.setOnItemClickListener(this);
        setContentView(listView);
    } catch (IOException e) {
    }
}
 
Example 25
Project: FlashCards   File: LoginActivity.java   View source code 5 votes vote down vote up
private void addEmailsToAutoComplete(List<String> emailAddressCollection) {
    //Create adapter to tell the AutoCompleteTextView what to show in its dropdown list.
    ArrayAdapter<String> adapter =
            new ArrayAdapter<>(LoginActivity.this,
                    android.R.layout.simple_dropdown_item_1line, emailAddressCollection);

    mEmailView.setAdapter(adapter);
}
 
Example 26
Project: SSTVEncoder2   File: EditTextActivity.java   View source code 5 votes vote down vote up
private void initFontFamilySpinner(String familyName) {
    Spinner spinner = (Spinner) findViewById(R.id.edit_font_family);
    spinner.setOnItemSelectedListener(this);
    mFontFamilySet = new FontFamilySet();
    mSelectedFontFamily = mFontFamilySet.getFontFamily(familyName);
    mFontFamilyNameList = mFontFamilySet.getFontFamilyDisplayNameList();
    spinner.setAdapter(new ArrayAdapter<>(this,
            android.R.layout.simple_spinner_dropdown_item, mFontFamilyNameList));
    spinner.setSelection(mFontFamilyNameList.indexOf(mSelectedFontFamily.displayName));
}
 
Example 27
Project: Image-Text-Reader-And-Tools   File: NoteActivity.java   View source code 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    String[] names_of = fileList(); //arr.length
    int name_size = names_of.length;
    not=(LinearLayout)findViewById(R.id.not);
    ListView names = (ListView)findViewById(R.id.LIST);
    ArrayAdapter<String> nameAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, names_of);

    if (names_of.length<1){
        not.setVisibility(View.VISIBLE);
        names.setVisibility(View.GONE);
    }else {
        not.setVisibility(View.GONE);
        names.setVisibility(View.VISIBLE);
    }

    names.setAdapter(nameAdapter);

}
 
Example 28
Project: ChipRemoteLCD-Android   File: SendMessageActivity.java   View source code 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_send_message);
        Spinner spinner = (Spinner) findViewById(R.id.spinner);
// Create an ArrayAdapter using the string array and a default spinner layout
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.spinner_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
        spinner.setAdapter(adapter);
    }
 
Example 29
Project: revolution-irc   File: EditNotificationSettingsActivity.java   View source code 5 votes vote down vote up
private void refreshSpinner() {
    mSpinnerOptionUUIDs = new ArrayList<>();
    List<String> options = new ArrayList<>();
    options.add(mServerSpinner.getContext().getString(R.string.value_any));
    mSpinnerOptionUUIDs.add(null);
    for (ServerConfigData data :
            ServerConfigManager.getInstance(mServerSpinner.getContext()).getServers()) {
        options.add(data.name);
        mSpinnerOptionUUIDs.add(data.uuid);
    }
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(mServerSpinner.getContext(),
            R.layout.simple_spinner_item, android.R.id.text1, options);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mServerSpinner.setAdapter(spinnerAdapter);
}
 
Example 30
Project: OAuth-2.0-Cookbook   File: DashboardActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dashboard);

    usernameText = (TextView) findViewById(R.id.profile_username);
    emailText = (TextView) findViewById(R.id.profile_email);

    tokenStore = new TokenStore(this);

    if (new AuthenticationManager(this).isAuthenticated()) {
        // add some fake user entries
        ListView listView = (ListView) findViewById(R.id.dashboard_entries);
        listView.setAdapter(new ArrayAdapter<>(
            this, android.R.layout.simple_list_item_1,
            new String[] {"Entry 1"}));

        // button to retrieve user profile
        Button profileButton = (Button) findViewById(R.id.profile_button);
        profileButton.setOnClickListener(this);
    } else {
        Intent loginIntent = new Intent(this, MainActivity.class);
        startActivity(loginIntent);
        finish();
    }

}
 
Example 31
Project: ClassifyView   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ListView sampleList = (ListView) findViewById(R.id.sample_list);
    sampleList.setAdapter(new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1,getResources().getStringArray(R.array.list_name)));
    sampleList.setOnItemClickListener(this);
}
 
Example 32
Project: encdroidMC   File: ConfigSyncActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_config_sync);
	

	
	volumeName = (EditText) findViewById(R.id.volumeName);
	//volumeName.setFocusable(false);
	
	volumePath = (EditText) findViewById(R.id.volumePath);
	//volumePath.setFocusable(false);
	
	password = (EditText) findViewById(R.id.volumePassword);
	password.setTransformationMethod(PasswordTransformationMethod.getInstance());
	password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); 
	
	onlyWifiCheckBox = ((CheckBox) findViewById(R.id.onlyWifi));
	removeAfterCheckBox = ((CheckBox) findViewById(R.id.removeAfter));
	localFolder = ((EditText) findViewById(R.id.localFolder));
	syncID = ((EditText) findViewById(R.id.syncID));
	syncID.setFocusable(false);
	
	
	spin1=(Spinner) findViewById(R.id.selectedRule);
	ArrayAdapter<String> adapter=new ArrayAdapter<String>(ConfigSyncActivity.this, android.R.layout.simple_spinner_item, rules);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	spin1.setAdapter(adapter);
	spin1.setOnTouchListener(this);
	spin1.setOnItemSelectedListener((OnItemSelectedListener) this);
	
	refresh(null);

	
}
 
Example 33
Project: aar   File: MainPresentImpl.java   View source code 5 votes vote down vote up
public MainPresentImpl(Context context, IMainView mainView) {
	this.context = context;
	this.mainView = mainView;
	if (adapter == null)
		adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, new String[] {
				"SDK.getInstance().init();",
				"SDK.getInstance().search(key);",
		});
}
 
Example 34
Project: eazycore   File: BaseNavigationDrawerActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    lvDrawer = (ListView) findViewById(R.id.left_drawer);
    lvDrawer.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1
            , getTitleMenus()));
    lvDrawer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

        }
    });
}
 
Example 35
Project: opentrivia   File: MainActivityFragment.java   View source code 5 votes vote down vote up
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  categorySpinnerAdapter =
      new ArrayAdapter<>(getActivity(), R.layout.support_simple_spinner_dropdown_item,
          new ArrayList<>());
  categoriesSpinner.setAdapter(categorySpinnerAdapter);

  ArrayAdapter<String> difficultySpinnerAdapter =
      new ArrayAdapter<>(getActivity(), R.layout.support_simple_spinner_dropdown_item,
          difficulties);
  difficultiesSpinner.setAdapter(difficultySpinnerAdapter);

  ArrayAdapter<String> gameTypeSpinnerAdapter =
      new ArrayAdapter<>(getActivity(), R.layout.support_simple_spinner_dropdown_item, gameTypes);
  gameTypesSpinner.setAdapter(gameTypeSpinnerAdapter);

  ArrayAdapter<String> amountsSpinnerAdapter =
      new ArrayAdapter<>(getActivity(), R.layout.support_simple_spinner_dropdown_item, amounts);
  amountsSpinner.setAdapter(amountsSpinnerAdapter);

  presenter.subscribe(savedInstanceState != null ? Parcels.unwrap(
      savedInstanceState.getParcelable(MainState.CATEGORY_STATE_KEY)) : null);

  categoriesSpinner.setSelection(
      savedInstanceState != null ? savedInstanceState.getInt(CATEGORIES_POSITION_KEY) : 0);
  difficultiesSpinner.setSelection(
      savedInstanceState != null ? savedInstanceState.getInt(DIFFICULTIES_POSITION_KEY) : 0);
  gameTypesSpinner.setSelection(
      savedInstanceState != null ? savedInstanceState.getInt(GAMETYPE_POSITION_KEY) : 0);
  amountsSpinner.setSelection(
      savedInstanceState != null ? savedInstanceState.getInt(GAMETYPE_POSITION_KEY) : 0);
}
 
Example 36
Project: medialibrary   File: AlbumActivity.java   View source code 5 votes vote down vote up
private void setupSpinner() {
    Spinner spinner = findViewById(R.id.spinner);
    spinner.setOnItemSelectedListener(mMainItemSelected);

    List<String> categories = new ArrayList<>();

    categories.add("All");
    categories.add("Photos");
    categories.add("Videos");


    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(dataAdapter);

    Spinner spinnerFilter = findViewById(R.id.spinnerFilter);
    spinnerFilter.setOnItemSelectedListener(mFilterItemSelected);

    List<String> filter = new ArrayList<>();

    filter.add("CLUSTER BY ALBUM");
    filter.add("CLUSTER BY TIME");
    filter.add("CLUSTER BY LOCATION");
    filter.add("CLUSTER BY TAG");
    filter.add("CLUSTER BY SIZE");
    filter.add("CLUSTER BY FACE");


    ArrayAdapter<String> dataAdapterFilter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, filter);
    dataAdapterFilter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerFilter.setAdapter(dataAdapterFilter);

}
 
Example 37
Project: stynico   File: HistoryAPIActivity.java   View source code 5 votes vote down vote up
public void onItemSelected(AdapterView<?> parent, View view, int position,
		       long id)
   {
if (parent.equals(spMonth))
{
    spDay.setAdapter(new ArrayAdapter<String>(this, R.layout.view_spinner, getDays(position + 1)));
    spDay.setSelection(Integer.parseInt(currentDay) - 1);
}
else if (parent.equals(spDay))
{
    currentDay = Integer.toString(position + 1);
    String date = "" + spMonth.getSelectedItem() + spDay.getSelectedItem();
    api.queryHistory(date, this);
}
   }
 
Example 38
Project: QMUI_Android   File: QDPopupFragment.java   View source code 5 votes vote down vote up
private void initListPopupIfNeed() {
    if (mListPopup == null) {

        String[] listItems = new String[]{
                "Item 1",
                "Item 2",
                "Item 3",
                "Item 4",
                "Item 5",
        };
        List<String> data = new ArrayList<>();

        Collections.addAll(data, listItems);

        ArrayAdapter adapter = new ArrayAdapter<>(getActivity(), R.layout.simple_list_item, data);

        mListPopup = new QMUIListPopup(getContext(), QMUIPopup.DIRECTION_NONE, adapter);
        mListPopup.create(QMUIDisplayHelper.dp2px(getContext(), 250), QMUIDisplayHelper.dp2px(getContext(), 200), new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(getActivity(), "Item " + (i + 1), Toast.LENGTH_SHORT).show();
                mListPopup.dismiss();
            }
        });
        mListPopup.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mActionButton2.setText(getContext().getResources().getString(R.string.popup_list_action_button_text_show));
            }
        });
    }
}
 
Example 39
Project: financisto1-holo   File: RecurActivity.java   View source code 5 votes vote down vote up
private void addSpinnerItems(Spinner spinner, LocalizableEnum[] a) {
	int length = a.length;
	SpinnerItem[] items = new SpinnerItem[length];
	for (int i=0; i<length; i++) {
		LocalizableEnum x = a[i];
		String title = getString(x.getTitleId());
		String value = x.name();
		items[i] = new SpinnerItem(title, value);
	}
	ArrayAdapter<SpinnerItem> adapter = new ArrayAdapter<SpinnerItem>(this, android.R.layout.simple_spinner_item, items);
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	spinner.setAdapter(adapter);
}
 
Example 40
Project: ShotsNewsApp   File: LoginActivity.java   View source code 5 votes vote down vote up
private void addEmailsToAutoComplete(List<String> emailAddressCollection) {
    //Create adapter to tell the AutoCompleteTextView what to show in its dropdown list.
    ArrayAdapter<String> adapter =
            new ArrayAdapter<>(LoginActivity.this,
                    android.R.layout.simple_dropdown_item_1line, emailAddressCollection);

    mEmailView.setAdapter(adapter);
}