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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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: bluewatcher   File: GenericNotificationsActivity.java   Source Code and License 6 votes vote down vote up
private void updateGenericApps() {
	orderedAppNames = new ArrayList<String>();
	for (GenericAppConfig app : genericAppConfigs) {
		orderedAppNames.add(app.getAppDisplayName());
	}
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, orderedAppNames);
	adapter.sort(new Comparator<String>() {
		@Override
		public int compare(String lhs, String rhs) {
			return lhs.compareTo(rhs);
		}
	});
	listView.setAdapter(adapter);
}
 
Example 12
Project: GitHub   File: MainActivity.java   Source Code and License 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 13
Project: QianXun   File: WBStatusAPIActivity.java   Source Code and License 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 14
Project: GitHub   File: BitmapAnimationCacheSelectorConfigurator.java   Source Code and License 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 15
Project: eBread   File: SettingTTSFragment.java   Source Code and License 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 16
Project: Plus1s   File: FoundViewActivity.java   Source Code and License 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 17
Project: AndroidNewArchitectureExample   File: CityListFragment.java   Source Code and License 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 18
Project: Aurora   File: SwitchVideoTypeDialog.java   Source Code and License 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 19
Project: tuxguitar   File: TGBrowserView.java   Source Code and License 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 20
Project: AndiCar   File: BackupListActivity.java   Source Code and License 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 21
Project: project-weather   File: ChooseAreaFragment.java   Source Code and License 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 22
Project: SkinFramework   File: SkinFragment.java   Source Code and License 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 23
Project: weather-mvp   File: ChooseAreaActivity.java   Source Code and License 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 24
Project: CycleViewPager   File: WorkInListViewActivity.java   Source Code and License 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 25
Project: HtmlNative   File: ExampleListActivity.java   Source Code and License 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 26
Project: FlashCards   File: LoginActivity.java   Source Code and License 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 27
Project: SSTVEncoder2   File: EditTextActivity.java   Source Code and License 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 28
Project: Image-Text-Reader-And-Tools   File: NoteActivity.java   Source Code and License 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 29
Project: ChipRemoteLCD-Android   File: SendMessageActivity.java   Source Code and License 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 30
Project: revolution-irc   File: EditNotificationSettingsActivity.java   Source Code and License 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 31
Project: OAuth-2.0-Cookbook   File: DashboardActivity.java   Source Code and License 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 32
Project: ClassifyView   File: MainActivity.java   Source Code and License 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 33
Project: encdroidMC   File: ConfigSyncActivity.java   Source Code and License 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 34
Project: aar   File: MainPresentImpl.java   Source Code and License 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 35
Project: eazycore   File: BaseNavigationDrawerActivity.java   Source Code and License 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 36
Project: opentrivia   File: MainActivityFragment.java   Source Code and License 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 37
Project: medialibrary   File: AlbumActivity.java   Source Code and License 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 38
Project: stynico   File: HistoryAPIActivity.java   Source Code and License 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 39
Project: QMUI_Android   File: QDPopupFragment.java   Source Code and License 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 40
Project: financisto1-holo   File: RecurActivity.java   Source Code and License 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 41
Project: ShotsNewsApp   File: LoginActivity.java   Source Code and License 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 42
Project: PopupWindow   File: PopupActivity.java   Source Code and License 5 votes vote down vote up
private void initPopupWindow() {
    // get the height of screen
    DisplayMetrics metrics=new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int screenHeight=metrics.heightPixels;
    // create popup window
    window=new CommonPopupWindow(this, R.layout.popup_list, ViewGroup.LayoutParams.MATCH_PARENT, (int) (screenHeight*0.7)) {
        @Override
        protected void initView() {
            View view=getContentView();
            dataList=(ListView) view.findViewById(R.id.data_list);
            dataList.setAdapter(new ArrayAdapter<String>(PopupActivity.this, R.layout.item_popup_list, datas));
        }

        @Override
        protected void initEvent() {
            dataList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    window.getPopupWindow().dismiss();
                }
            });
        }

        @Override
        protected void initWindow() {
            super.initWindow();
            PopupWindow instance=getPopupWindow();
            instance.setOnDismissListener(new PopupWindow.OnDismissListener() {
                @Override
                public void onDismiss() {
                    WindowManager.LayoutParams lp=getWindow().getAttributes();
                    lp.alpha=1.0f;
                    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                    getWindow().setAttributes(lp);
                }
            });
        }
    };
}
 
Example 43
Project: LifeHelper   File: AboutSoftwareActivity.java   Source Code and License 5 votes vote down vote up
private void initView() {
    mSoftwareInfo = (ListView) findViewById(R.id.software_info);
    mStringList.add("应用名:" + getString(R.string.app_name));
    mStringList.add("版本号:" + UtilTools.getVersion(this));
    mStringList.add("开发者博客:http://blog.csdn.net/hultron");

    mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mStringList);
    //设置适配器
    mSoftwareInfo.setAdapter(mAdapter);
}
 
Example 44
Project: Android-BLE-to-Arduino   File: DeviceControlActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client.connect();

    // change view for chat
    setContentView(R.layout.communication_layout);

    // Initialize the array adapter for the conversation
    mConversationArrayAdapter = new ArrayAdapter<String>(this,
            R.layout.message);
    mConversationView = (ListView) findViewById(R.id.in);
    mConversationView.setAdapter(mConversationArrayAdapter);

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    Action viewAction = Action.newAction(
            Action.TYPE_VIEW, // TODO: choose an action type.
            "DeviceControl Page", // TODO: Define a title for the content shown.
            // TODO: If you have web page content that matches this app activity's content,
            // make sure this auto-generated web page URL is correct.
            // Otherwise, set the URL to null.
            Uri.parse("http://host/path"),
            // TODO: Make sure this auto-generated app URL is correct.
            Uri.parse("android-app://com.example.android.bluetoothlechat/http/host/path")
    );
    AppIndex.AppIndexApi.start(client, viewAction);
}
 
Example 45
Project: GSB-2017-Android   File: SpinnersHelper.java   Source Code and License 5 votes vote down vote up
public static void populateSupplierSpinner(final Context context, final Spinner spinnerSuppliers , final CompositeDisposable compositeDisposable) {
    SuppliersNetworkCalls.getAllSuppliers().subscribe(new Observer<List<Supplier>>() {
        @Override
        public void onSubscribe(Disposable d) {
            compositeDisposable.add(d);
        }

        @Override
        public void onNext(List<Supplier> value) {
            ArrayList<String> date = new ArrayList<>();
            for (Supplier supplier : value) {
                date.add(String.valueOf(supplier.getNameSup()));
            }
            ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, date);
            spinnerSuppliers.setAdapter(adapter);
        }

        @Override
        public void onError(Throwable e) {
            Log.e("Get Suppliers" , "Error getting suppliers" , e);
            if(e instanceof SocketException || e instanceof IOException) {
                Toast.makeText(context , R.string.no_internet , Toast.LENGTH_SHORT).show();
            } else if (e instanceof Exception) {
                Toast.makeText(context , e.getMessage() , Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void onComplete() {

        }
    });
}
 
Example 46
Project: ImageClassify   File: ShowFinishedTaskDetailActivity.java   Source Code and License 5 votes vote down vote up
private void setTaskDetail() {
    CommonAdapter<FinishedTaskImageDetail> taskItemDetailAdapter = new CommonAdapter<FinishedTaskImageDetail>(this, R.layout.finished_task_detail_item, taskList) {
        @Override
        protected void convert(ViewHolder viewHolder, FinishedTaskImageDetail item, int position) {
            ImageView taskImageView = viewHolder.getView(R.id.id_finished_task_image_view);
            Glide.with(ShowFinishedTaskDetailActivity.this)
                    .load(item.getImg_path())
                    .placeholder(R.drawable.ic_user_default_avatar)
                    .centerCrop()
                    .dontAnimate()
                    .into(taskImageView);
            mShowFinishedTaskDetailPresenter.getLabels(item.getUser_labels(), item.getFinal_labels());
            if (confirmLabels.size() != 0) {
                GridView confirmLabelGridView = viewHolder.getView(R.id.id_confirm_task_label_grid_view);
                confirmLabelGridView.setAdapter(new ArrayAdapter<>(ShowFinishedTaskDetailActivity.this,
                        R.layout.confirm_task_label, confirmLabels));
            }
            if (unconfirmLabels.size() != 0) {
                GridView unconfirmLabelGridView = viewHolder.getView(R.id.id_unconfirm_task_label_grid_view);
                unconfirmLabelGridView.setAdapter(new ArrayAdapter<>(ShowFinishedTaskDetailActivity.this,
                        R.layout.unconfirm_task_label, unconfirmLabels));
            }
            TextView accuracyTextView =  viewHolder.getView(R.id.id_image_accuracy);
            if(TextUtils.isEmpty(item.getAccuracy()) || item.getAccuracy().equals("null")){
                accuracyTextView.setText("准确度 0.0%");
            }else {
                String accuracyStr = String.format("%.1f",100*Float.parseFloat(item.getAccuracy()));
                accuracyTextView.setText("准确度 "+ accuracyStr+"%");
            }
        }
    };
    finishedTaskGridView.setAdapter(taskItemDetailAdapter);
}
 
Example 47
Project: GitHub   File: EditTextInfoActivity.java   Source Code and License 5 votes vote down vote up
/**显示列表内容
 * @author author
 * @param list
 */
private void setList(List<String> list) {
	if (hasList == false || list == null || list.size() <= 0) {
		Log.i(TAG, "setList list == null || list.size() <= 0 >> adapter = null;lvEditTextInfo.setAdapter(null); return;");
		adapter = null;
		lvEditTextInfo.setAdapter(null);
		return;
	}

	adapter = new ArrayAdapter<String>(context, R.layout.list_item, R.id.tvListItem, list);
	lvEditTextInfo.setAdapter(adapter);
	//			if (hasUrl) {
	//			}
	lvEditTextInfo.smoothScrollBy(60, 200);
}
 
Example 48
Project: ChipsLayoutManager   File: ItemsFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);

    adapter = createAdapter(savedInstanceState);

    ChipsLayoutManager spanLayoutManager = ChipsLayoutManager.newBuilder(getContext())
            .setOrientation(ChipsLayoutManager.HORIZONTAL)
            .build();

    rvTest.addItemDecoration(new SpacingItemDecoration(getResources().getDimensionPixelOffset(R.dimen.item_space),
            getResources().getDimensionPixelOffset(R.dimen.item_space)));

    positions = new LinkedList<>();
    for (int i = 0; i< items.size(); i++) {
        positions.add(String.valueOf(i));
    }

    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, positions);
    ArrayAdapter<String> spinnerAdapterMoveTo = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, positions);
    spinnerPosition.setAdapter(spinnerAdapter);
    spinnerMoveTo.setAdapter(spinnerAdapterMoveTo);

    rvTest.setLayoutManager(spanLayoutManager);
    rvTest.getRecycledViewPool().setMaxRecycledViews(0, 10);
    rvTest.getRecycledViewPool().setMaxRecycledViews(1, 10);
    rvTest.setAdapter(adapter);

}
 
Example 49
Project: GitHub   File: SearchViewActivity.java   Source Code and License 5 votes vote down vote up
/**
 * 模糊查找音乐
 * @param key
 */
private void quertMusic(String key) {
    String[] musics = new String[]{};
    if (!TextUtils.isEmpty(key)){
        musics = FileUtils.queryMusic(this, key);
    }
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, musics);
    mLvMusic.setAdapter(adapter);
}
 
Example 50
Project: Quran   File: AyahPlaybackFragment.java   Source Code and License 5 votes vote down vote up
private ArrayAdapter<CharSequence> initializeAyahSpinner(
    Context context, QuranSpinner spinner) {
  final ArrayAdapter<CharSequence> ayahAdapter =
      new ArrayAdapter<>(context, ITEM_LAYOUT);
  ayahAdapter.setDropDownViewResource(ITEM_DROPDOWN_LAYOUT);
  spinner.setAdapter(ayahAdapter);
  return ayahAdapter;
}
 
Example 51
Project: text_converter   File: CodecFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mInput = view.findViewById(R.id.edit_input);
    mInput.setBackgroundDrawable(RoundedBackgroundEditText.createRoundedBackground(getContext()));

    mOutput = view.findViewById(R.id.edit_output);
    mOutput.setBackgroundDrawable(RoundedBackgroundEditText.createRoundedBackground(getContext()));

    mInput.addTextChangedListener(mInputWatcher);
    mOutput.addTextChangedListener(mOutputWatcher);

    view.findViewById(R.id.image_paste).setOnClickListener(this);
    view.findViewById(R.id.image_paste_out).setOnClickListener(this);
    view.findViewById(R.id.img_copy).setOnClickListener(this);
    view.findViewById(R.id.img_copy_out).setOnClickListener(this);
    view.findViewById(R.id.img_share).setOnClickListener(this);
    view.findViewById(R.id.img_share_out).setOnClickListener(this);
    view.findViewById(R.id.img_encode_all).setOnClickListener(this);
    view.findViewById(R.id.img_decode_all).setOnClickListener(this);

    String[] data = getResources().getStringArray(R.array.codec_methods);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(),
            android.R.layout.simple_list_item_1, data);
    adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
    mMethodSpinner = view.findViewById(R.id.spinner_choose);
    mMethodSpinner.setBackgroundDrawable(RoundedBackgroundEditText.createRoundedBackground(getContext()));
    mMethodSpinner.setAdapter(adapter);
    mMethodSpinner.setOnItemSelectedListener(this);

    restore();
}
 
Example 52
Project: GitHub   File: XListViewActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onRefresh() {
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            mIndex = ++mRefreshIndex;
            items.clear();
            geneItems();
            mAdapter = new ArrayAdapter<String>(XListViewActivity.this, R.layout.vw_list_item,
                    items);
            mListView.setAdapter(mAdapter);
            onLoad();
        }
    }, 2500);
}
 
Example 53
Project: revolution-irc   File: MessageFormatSettingsActivity.java   Source Code and License 5 votes vote down vote up
private void selectPreset(EditText editText, CharSequence[] presets) {
    ListPopupWindow menu = new ListPopupWindow(editText.getContext());
    menu.setAnchorView(editText);
    menu.setAdapter(new ArrayAdapter<>(this,
            R.layout.activity_message_format_settings_preset, presets));
    menu.setOnItemClickListener((AdapterView<?> parent, View view, int position, long id) -> {
        editText.setText(presets[position]);
        menu.dismiss();
    });
    menu.show();
}
 
Example 54
Project: ConnectU   File: PreferenceMenuFragment.java   Source Code and License 5 votes vote down vote up
private void setYearAdapters() {
    List<String> years = new ArrayList<>();
    if (app.academicYears == null)
        return;
    for (AcademicYear year : app.academicYears) {
        years.add(year.getYear());
    }
    yearAdapter = new ArrayAdapter<>(getContext(), R.layout.view_dialog_select, years);
}
 
Example 55
Project: GitHub   File: BasicFunctions.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_loadmore);
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    ultimateRecyclerView = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
    doURV(ultimateRecyclerView);
    bButtons();
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
    setupSpinnerSelection((Spinner) findViewById(R.id.spinner), spinnerAdapter);
}
 
Example 56
Project: leoapp-sources   File: NewSurveyDialog.java   Source Code and License 5 votes vote down vote up
private void initSpinner() {

        if (stage != layouts.length - 1)
            return;

        Spinner s = findViewById(R.id.spinner2);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(Utils.getContext(),
                R.array.level, R.layout.spinner_item);
        adapter.setDropDownViewResource(R.layout.spinner_item);
        s.setAdapter(adapter);
    }
 
Example 57
Project: ConnectU   File: EvaluacionFilterDialog.java   Source Code and License 5 votes vote down vote up
private void setAdapters() {
    //Subject Filter
    List<String> subjects = ObjectHelper.getSubjectsName(getContext(), request.getYear(), true);
    namepAsignatura  = new ArrayAdapter<>(activity,  R.layout.spinner_item, subjects);
    namepAsignatura.setDropDownViewResource(R.layout.spinner_dropdown_item);

    //Type Filter
    List<String> orden = new ArrayList<>(Arrays.asList(activity.getResources().getStringArray(R.array.type_filters)));
    namepTipo  = new ArrayAdapter<>(activity,  R.layout.spinner_item, orden);
    namepTipo.setDropDownViewResource(R.layout.spinner_dropdown_item);
}
 
Example 58
Project: yass-android   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    prefs.registerOnSharedPreferenceChangeListener(listener);
    preferences = new YassPreferences(getApplicationContext());
    // TODO: if prefs not set, show settings

    client = getS3Client(preferences);

    this.mListView = (ListView) findViewById(R.id.blob_list_view);
    this.adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, listItems);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long arg3) {
            String path = prefix + listItems.get(position);
            if (listing.getCommonPrefixes().contains(path)) {
                MainActivity.this.prefix = path;
                new BlobListTask().execute(path);
            } else {
                new SelectBlobTask().execute(path);
            }
        }
    });
    // TODO: long press
    new BlobListTask().execute("");
}
 
Example 59
Project: TextFieldBoxes   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {

        final SharedPreferences sharedPreferences = this.getSharedPreferences("theme", Context.MODE_PRIVATE);
        final boolean dark = sharedPreferences.getBoolean("dark", false);
        setTheme(dark ? R.style.AppThemeDark : R.style.AppTheme);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        final TextFieldBoxes tfb = findViewById(R.id.text_field_boxes2);
        final ExtendedEditText t = findViewById(R.id.extendedEditText);

        final String[] aWords = {"Apple", "Android", "Alternative"};
        final ArrayAdapter<String> adapter = new ArrayAdapter<>
                (this, android.R.layout.select_dialog_item, aWords);
        t.setThreshold(1);
        t.setAdapter(adapter);

        final Button darkButton = findViewById(R.id.dark_button);

        darkButton.setText(dark ? "LIGHT SIDE" : "DARK SIDE");
        darkButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                sharedPreferences.edit().putBoolean("dark", !dark).apply();
                Intent i = getBaseContext().getPackageManager()
                        .getLaunchIntentForPackage(getBaseContext().getPackageName());
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(i);
            }
        });
    }
 
Example 60
Project: PickColorFromImageAndroid   File: PickColor.java   Source Code and License 5 votes vote down vote up
public void showCameraGalleryDialog() {

        ArrayList<String> optionItems=new ArrayList<String>();
        optionItems.add("Camera");
        optionItems.add("Gallery");

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("Choose Option");

        final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(  PickColor.this, android.R.layout.simple_list_item_1 ,optionItems) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View view = super.getView(position, convertView, parent);
                TextView text1 = (TextView) view.findViewById(android.R.id.text1);
                text1.setTextColor(Color.BLACK);
                return view;
            }
        };

        builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                    case 0:
                        Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                        startActivityForResult(cameraIntent, CAMERA_REQUEST);
                        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                        break;
                    case 1:
                        Intent pictureActionIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                        startActivityForResult(pictureActionIntent, GALLERY_PICTURE);
                        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                        break;
                }
            }
        });

        AlertDialog alertDialog = builder.create();
        alertDialog.show();
    }