use of android.widget.AdapterView in project TextJustify-Android by bluejamesbond.
the class TestList method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set default app font
// FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/notosans.ttf");
// Set layout
setContentView(R.layout.testlist_activity);
// Create list of simple test names
String[] testNames = new String[tests.length];
for (int i = 0; i < testNames.length; i++) {
testNames[i] = Utils.splitCamelCase(tests[i].getSimpleName()).toUpperCase();
}
// Get listView
ListView lv = (ListView) findViewById(R.id.list);
// Assign adapter to List
lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, testNames) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView textView = (TextView) view.findViewById(android.R.id.text1);
textView.setTypeface(Typeface.DEFAULT_BOLD);
textView.setBackgroundColor(Color.parseColor("#111111"));
textView.setTextColor(Color.WHITE);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
return view;
}
});
// For each click
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
startActivity(new Intent(TestList.this, tests[i]));
}
});
}
use of android.widget.AdapterView in project TwinklingRefreshLayout by lcodecorex.
the class ScienceActivity method setupGridView.
private void setupGridView(GridView gridView) {
final TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refresh);
SinaRefreshView headerView = new SinaRefreshView(this);
headerView.setArrowResource(R.drawable.arrow);
headerView.setTextColor(0xff745D5C);
// TextHeaderView headerView = (TextHeaderView) View.inflate(this,R.layout.header_tv,null);
refreshLayout.setHeaderView(headerView);
LoadingView loadingView = new LoadingView(this);
refreshLayout.setBottomView(loadingView);
adapter = new ScienceAdapter();
gridView.setAdapter(adapter);
adapter.refreshCard();
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
ToastUtil.show("item clicked!");
}
});
refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {
@Override
public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
adapter.refreshCard();
refreshLayout.finishRefreshing();
}
}, 2000);
}
@Override
public void onLoadMore(final TwinklingRefreshLayout refreshLayout) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
adapter.loadMoreCard();
refreshLayout.finishLoadmore();
}
}, 2000);
}
});
}
use of android.widget.AdapterView in project Shuttle by timusus.
the class EqualizerActivity method onCreate.
@SuppressLint("InlinedApi")
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@Override
public void onCreate(Bundle savedInstanceState) {
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
ThemeUtils.setTheme(this);
if (!ShuttleUtils.hasLollipop() && ShuttleUtils.hasKitKat()) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
mTintManager = new SystemBarTintManager(this);
}
if (!ShuttleUtils.hasKitKat()) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
}
if (SettingsManager.getInstance().canTintNavBar()) {
getWindow().setNavigationBarColor(ColorUtils.getPrimaryColorDark(this));
}
super.onCreate(savedInstanceState);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
setContentView(R.layout.activity_equalizer);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ThemeUtils.themeActionBar(this);
ThemeUtils.themeStatusBar(this, mTintManager);
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(getResources().getString(R.string.equalizer));
try {
//Query available effects
final AudioEffect.Descriptor[] effects = AudioEffect.queryEffects();
//Determine available/supported effects
if (effects != null && effects.length != 0) {
for (final AudioEffect.Descriptor effect : effects) {
//Equalizer
if (effect.type.equals(UUID.fromString(EFFECT_TYPE_EQUALIZER))) {
mEqualizerSupported = true;
} else if (effect.type.equals(UUID.fromString(EFFECT_TYPE_BASS_BOOST))) {
mBassBoostSupported = true;
} else if (effect.type.equals(UUID.fromString(EFFECT_TYPE_VIRTUALIZER))) {
mVirtualizerSupported = true;
}
}
}
} catch (NoClassDefFoundError ignored) {
//The user doesn't have the AudioEffect/AudioEffect.Descriptor class. How sad.
}
mSpinner = (Spinner) findViewById(R.id.eqSpinner);
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mEqPreset = position;
equalizerSetPreset(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
setupPresets();
if (mSpinnerAdapter != null && mSpinnerAdapter.getCount() > mEqPreset) {
mSpinner.setSelection(mEqPreset);
}
//Initialize the equalizer elements
View eqContainer = findViewById(R.id.eqContainer);
mNumberEqualizerBands = Integer.parseInt(mPrefs.getString("equalizer.number_of_bands", "5"));
final int[] centerFreqs = getCenterFreqs();
final int[] bandLevelRange = getBandLevelRange();
for (int band = 0; band < mNumberEqualizerBands; band++) {
//Unit conversion from mHz to Hz and use k prefix if necessary to display
float centerFreqHz = centerFreqs[band] / 1000;
String unitPrefix = "";
if (centerFreqHz >= 1000) {
centerFreqHz = centerFreqHz / 1000;
unitPrefix = "k";
}
(eqContainer.findViewById(eqViewElementIds[band][0])).setVisibility(View.VISIBLE);
(eqContainer.findViewById(eqViewTextElementIds[band][0])).setVisibility(View.VISIBLE);
(eqContainer.findViewById(eqViewElementIds[band][1])).setVisibility(View.VISIBLE);
(eqContainer.findViewById(eqViewTextElementIds[band][1])).setVisibility(View.VISIBLE);
((TextView) eqContainer.findViewById(eqViewElementIds[band][0])).setText(format("%.0f ", centerFreqHz) + unitPrefix + "Hz");
mEqualizerSeekBar[band] = (SizableSeekBar) eqContainer.findViewById(eqViewElementIds[band][1]);
ThemeUtils.themeSeekBar(this, mEqualizerSeekBar[band]);
mEqualizerSeekBar[band].setMax((bandLevelRange[1] / 100) - (bandLevelRange[0] / 100));
mEqualizerSeekBar[band].setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
if (fromUser) {
//Determine which band changed
int seekbarId = seekBar.getId();
int band = 0;
for (int i = 0; i < eqViewElementIds.length; i++) {
if (eqViewElementIds[i][1] == seekbarId) {
band = i;
}
}
if (mEqPreset != mEqCustomPresetPosition) {
equalizerCopyToCustom();
if (mSpinnerAdapter != null && mSpinnerAdapter.getCount() > mEqCustomPresetPosition) {
mSpinner.setSelection(mEqCustomPresetPosition);
}
} else {
int level = getBandLevelRange()[0] + (progress * 100);
equalizerBandUpdate(band, level);
}
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
}
});
}
// Set the SeekBar listener.
if (mBassBoostSupported) {
final SizableSeekBar seekbar = (SizableSeekBar) findViewById(R.id.bb_strength);
ThemeUtils.themeSeekBar(this, seekbar);
seekbar.setMax(OpenSLESConstants.BASSBOOST_MAX_STRENGTH - OpenSLESConstants.BASSBOOST_MIN_STRENGTH);
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
// set parameter and state
if (fromUser) {
mPrefs.edit().putBoolean("audiofx.bass.enable", true).apply();
mPrefs.edit().putString("audiofx.bass.strength", String.valueOf(progress)).apply();
mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
}
}
// If slider pos was 0 when starting re-enable effect
@Override
public void onStartTrackingTouch(final SeekBar seekBar) {
if (seekBar.getProgress() == 0) {
mPrefs.edit().putBoolean("audiofx.bass.enable", true).apply();
mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
}
}
// If slider pos = 0 when stopping disable effect
@Override
public void onStopTrackingTouch(final SeekBar seekBar) {
if (seekBar.getProgress() == 0) {
// disable
mPrefs.edit().putBoolean("audiofx.bass.enable", false).apply();
mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
}
}
});
}
// Set the SeekBar listener.
if (mVirtualizerSupported) {
final SizableSeekBar seekbar = (SizableSeekBar) findViewById(R.id.virtualizer_strength);
ThemeUtils.themeSeekBar(this, seekbar);
seekbar.setMax(OpenSLESConstants.VIRTUALIZER_MAX_STRENGTH - OpenSLESConstants.VIRTUALIZER_MIN_STRENGTH);
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
// set parameter and state
if (fromUser) {
mPrefs.edit().putBoolean("audiofx.virtualizer.enable", true).apply();
mPrefs.edit().putString("audiofx.virtualizer.strength", String.valueOf(progress)).apply();
mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
}
}
// If slider pos was 0 when starting re-enable effect
@Override
public void onStartTrackingTouch(final SeekBar seekBar) {
if (seekBar.getProgress() == 0) {
mPrefs.edit().putBoolean("audiofx.virtualizer.enable", true).apply();
mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
}
}
// If slider pos = 0 when stopping disable effect
@Override
public void onStopTrackingTouch(final SeekBar seekBar) {
if (seekBar.getProgress() == 0) {
// disable
mPrefs.edit().putBoolean("audiofx.virtualizer.enable", false).apply();
mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
}
}
});
}
}
use of android.widget.AdapterView in project SwipeMenuListView by baoyongzhang.
the class SimpleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
mAppList = getPackageManager().getInstalledApplications(0);
mListView = (SwipeMenuListView) findViewById(R.id.listView);
mAdapter = new AppAdapter();
mListView.setAdapter(mAdapter);
// step 1. create a MenuCreator
SwipeMenuCreator creator = new SwipeMenuCreator() {
@Override
public void create(SwipeMenu menu) {
// create "open" item
SwipeMenuItem openItem = new SwipeMenuItem(getApplicationContext());
// set item background
openItem.setBackground(new ColorDrawable(Color.rgb(0xC9, 0xC9, 0xCE)));
// set item width
openItem.setWidth(dp2px(90));
// set item title
openItem.setTitle("Open");
// set item title fontsize
openItem.setTitleSize(18);
// set item title font color
openItem.setTitleColor(Color.WHITE);
// add to menu
menu.addMenuItem(openItem);
// create "delete" item
SwipeMenuItem deleteItem = new SwipeMenuItem(getApplicationContext());
// set item background
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9, 0x3F, 0x25)));
// set item width
deleteItem.setWidth(dp2px(90));
// set a icon
deleteItem.setIcon(R.drawable.ic_delete);
// add to menu
menu.addMenuItem(deleteItem);
}
};
// set creator
mListView.setMenuCreator(creator);
// step 2. listener item click event
mListView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
ApplicationInfo item = mAppList.get(position);
switch(index) {
case 0:
// open
open(item);
break;
case 1:
// delete
// delete(item);
mAppList.remove(position);
mAdapter.notifyDataSetChanged();
break;
}
return false;
}
});
// set SwipeListener
mListView.setOnSwipeListener(new SwipeMenuListView.OnSwipeListener() {
@Override
public void onSwipeStart(int position) {
// swipe start
}
@Override
public void onSwipeEnd(int position) {
// swipe end
}
});
// set MenuStateChangeListener
mListView.setOnMenuStateChangeListener(new SwipeMenuListView.OnMenuStateChangeListener() {
@Override
public void onMenuOpen(int position) {
}
@Override
public void onMenuClose(int position) {
}
});
// other setting
// listView.setCloseInterpolator(new BounceInterpolator());
// test item long click
mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(), position + " long click", Toast.LENGTH_SHORT).show();
return false;
}
});
}
use of android.widget.AdapterView in project glimmr by brk3.
the class LocalPhotosGridFragment method initGridView.
@Override
protected void initGridView() {
mGridView = (GridView) mLayout.findViewById(R.id.gridview);
mGridView.setVisibility(View.VISIBLE);
mGridView.setMultiChoiceModeListener(this);
mShowDetailsOverlay = false;
String[] from = { MediaStore.MediaColumns.TITLE };
int[] to = { android.R.id.text1 };
CursorLoader cursorLoader = new CursorLoader(getActivity(), SOURCE_URI, null, null, null, MediaStore.Audio.Media.TITLE);
Cursor cursor = cursorLoader.loadInBackground();
mAdapter = new MediaStoreImagesAdapter(getActivity(), R.layout.gridview_item, cursor, from, to);
mGridView.setAdapter(mAdapter);
mGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL);
mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
final String usageTip = getString(R.string.upload_photos_tip);
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
UsageTips.getInstance().show(mActivity, usageTip, true);
}
});
}
Aggregations