List of usage examples for android.widget ListView ListView
public ListView(Context context)
From source file:net.alexjf.tmm.fragments.ImmedTransactionStatsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (colors == null) { colors = new int[] { getResources().getColor(R.color.pie1), getResources().getColor(R.color.pie2), getResources().getColor(R.color.pie3), getResources().getColor(R.color.pie4), getResources().getColor(R.color.pie5), getResources().getColor(R.color.pie6), getResources().getColor(R.color.pie7), getResources().getColor(R.color.pie8), getResources().getColor(R.color.pie9), getResources().getColor(R.color.pie10) }; }/*from ww w .j a v a2s. c om*/ View v = inflater.inflate(R.layout.fragment_immedtransaction_stats, container, false); transactionTypeSpinner = (Spinner) v.findViewById(R.id.transaction_type_spinner); LinearLayout layout = (LinearLayout) v.findViewById(R.id.stats); Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { layout.setOrientation(LinearLayout.HORIZONTAL); } renderer.setZoomEnabled(false); renderer.setLabelsTextSize(Utils.displayPixelsToPixels(getActivity(), 12)); renderer.setZoomButtonsVisible(false); renderer.setStartAngle(90); renderer.setInScroll(true); renderer.setPanEnabled(false); renderer.setScale(0.8f); renderer.setShowLabels(true); renderer.setShowLegend(false); chartView = ChartFactory.getPieChartView(this.getActivity(), dataSet, renderer); chartView.setLayoutParams(new ListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Utils.displayPixelsToPixels(getActivity(), 250))); percentagesListView = new ListView(getActivity()); catPercentageAdapter = new CategoryPercentageAdapter(getActivity()); percentagesListView.addHeaderView(chartView); percentagesListView.setAdapter(catPercentageAdapter); layout.addView(percentagesListView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1)); if (savedInstanceState != null) { int selectedSpinnerPosition = savedInstanceState.getInt(KEY_SPINNERSELECTION); transactionTypeSpinner.setOnItemSelectedListener(null); transactionTypeSpinner.setSelection(selectedSpinnerPosition); } transactionTypeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: currentFilter = incomeFilter; break; case 1: currentFilter = expenseFilter; break; } updateCurrentTransactionSet(); } public void onNothingSelected(AdapterView<?> arg0) { currentFilter = incomeFilter; } }); if (categoryStatsTask != null) { categoryStatsTask.setContext(getActivity()); categoryStatsTask.setResultListener(this); } return v; }
From source file:org.dvbviewer.controller.ui.base.BaseListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a ListView whose id * is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} * that is to be shown when the list is empty. * //from w w w . java 2 s .c o m * <p>If you are overriding this method with your own custom content, * consider including the standard layout {@link android.R.layout#list_content} * in your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only * way to have the built-in indeterminant progress state be shown. * * @param inflater the inflater * @param container the container * @param savedInstanceState the saved instance state * @return the view * @author RayBa * @date 07.04.2013 */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); if (layoutRessource > 0) { View v = getLayoutInflater(savedInstanceState).inflate(layoutRessource, null); return v; } else { FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyle); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; } }
From source file:cn.njmeter.njmeter.widget.spinner.NiceSpinner.java
private void init(Context context, AttributeSet attrs) { Resources resources = getResources(); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NiceSpinner); int defaultPadding = resources.getDimensionPixelSize(R.dimen.one_and_a_half_grid_unit); setGravity(Gravity.CENTER_VERTICAL | Gravity.START); setPadding(resources.getDimensionPixelSize(R.dimen.three_grid_unit), defaultPadding, defaultPadding, defaultPadding);/* www .j a va 2 s. c o m*/ setClickable(true); backgroundSelector = typedArray.getResourceId(R.styleable.NiceSpinner_backgroundSelector, R.drawable.selector); setBackgroundResource(backgroundSelector); textColor = typedArray.getColor(R.styleable.NiceSpinner_textTint, getDefaultTextColor(context)); setTextColor(textColor); listView = new ListView(context); // Set the spinner's id into the listview to make it pretend to be the right parent in // onItemClick listView.setId(getId()); listView.setDivider(new ColorDrawable(Color.GRAY)); listView.setDividerHeight(1); listView.setItemsCanFocus(true); //hide vertical and horizontal scrollbars listView.setVerticalScrollBarEnabled(false); listView.setHorizontalScrollBarEnabled(false); listView.setOverScrollMode(OVER_SCROLL_NEVER); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { selectedIndex = position; if (onItemClickListener != null) { onItemClickListener.onItemClick(parent, view, position, id); } if (onItemSelectedListener != null) { onItemSelectedListener.onItemSelected(parent, view, position, id); } adapter.setSelectedIndex(position); setTextInternal(adapter.getItemInDataset(position).toString()); dismissDropDown(); } }); popupWindow = new PopupWindow(context); popupWindow.setContentView(listView); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { popupWindow.setElevation(DEFAULT_ELEVATION); popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.spinner_drawable)); } else { popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.drop_down_shadow)); } popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { if (!isArrowHidden) { animateArrow(false); } } }); isArrowHidden = typedArray.getBoolean(R.styleable.NiceSpinner_hideArrow, false); arrowDrawableTint = typedArray.getColor(R.styleable.NiceSpinner_arrowTint, Integer.MAX_VALUE); arrowDrawableResId = typedArray.getResourceId(R.styleable.NiceSpinner_arrowDrawable, R.drawable.arrow); dropDownListPaddingBottom = typedArray .getDimensionPixelSize(R.styleable.NiceSpinner_dropDownListPaddingBottom, 0); typedArray.recycle(); measureDisplayHeight(); }
From source file:hcm.ssj.creator.dialogs.FileDialog.java
/** * @param savedInstanceState Bundle//from w w w .j ava2 s. c o m * @return Dialog */ @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(titleMessage); builder.setPositiveButton(R.string.str_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { switch (type) { case SAVE: { String fileName = editText.getText().toString().trim(); File dir1 = new File(Environment.getExternalStorageDirectory(), Util.DIR_1); File dir2 = new File(dir1.getPath(), Util.DIR_2); if (!fileName.isEmpty() && (dir2.exists() || dir2.mkdirs())) { if (!fileName.endsWith(Util.SUFFIX)) { fileName += Util.SUFFIX; } File file = new File(dir2, fileName); if (isValidFileName(file) && SaveLoad.save(file)) { for (Listener listener : alListeners) { listener.onPositiveEvent(null); } return; } } for (Listener listener : alListeners) { listener.onNegativeEvent(new Boolean[] { false }); } return; } case LOAD: case DELETE: { if (xmlFiles != null && xmlFiles.length > 0) { int pos = listView.getCheckedItemPosition(); if (pos > AbsListView.INVALID_POSITION) { if (type == Type.DELETE && xmlFiles[pos].delete()) { for (Listener listener : alListeners) { listener.onPositiveEvent(null); } return; } else if (type == Type.LOAD) { if (SaveLoad.load(xmlFiles[pos])) { for (Listener listener : alListeners) { listener.onPositiveEvent(null); } return; } } for (Listener listener : alListeners) { listener.onNegativeEvent(new Boolean[] { false }); } return; } } for (Listener listener : alListeners) { listener.onNegativeEvent(null); } break; } } } }); builder.setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { for (Listener listener : alListeners) { listener.onNegativeEvent(null); } } }); //set up the input switch (type) { case SAVE: { editText = new EditText(getContext()); editText.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); editText.setInputType(InputType.TYPE_CLASS_TEXT); builder.setView(editText); break; } case LOAD: case DELETE: { listView = new ListView(getContext()); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); File dir1 = new File(Environment.getExternalStorageDirectory(), Util.DIR_1); File dir2 = new File(dir1.getPath(), Util.DIR_2); xmlFiles = dir2.listFiles(new FilenameFilter() { @Override public boolean accept(File folder, String name) { return name.toLowerCase().endsWith(Util.SUFFIX); } }); if (xmlFiles != null && xmlFiles.length > 0) { String[] ids = new String[xmlFiles.length]; for (int i = 0; i < ids.length; i++) { ids[i] = xmlFiles[i].getName(); } listView.setAdapter( new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_single_choice, ids)); } else { listView.setAdapter( new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_single_choice)); } builder.setView(listView); break; } } return builder.create(); }
From source file:org.musicbrainz.mobile.activity.DashboardActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == IntentIntegrator.BARCODE_REQUEST) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanResult.getContents() != null) { Intent barcodeResult = new Intent(this, ReleaseActivity.class); barcodeResult.putExtra(Extra.BARCODE, scanResult.getContents()); startActivity(barcodeResult); }//from ww w . j a va 2 s . co m } else if (requestCode == COLLECTION_LOGIN_REQUEST && isUserLoggedIn()) { startActivity(IntentFactory.getCollectionList(getApplicationContext())); } else if (intent != null) { if (resultCode == Activity.RESULT_OK) { ArrayList<String> matches = intent.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Did you say?"); final ListView modeList = new ListView(this); String[] arrayMatches = matches.toArray(new String[matches.size()]); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.activity_voicetotexts, R.id.voicetotexts_item, arrayMatches); modeList.setAdapter(adapter); builder.setView(modeList); final Dialog dialog = builder.create(); modeList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String selectedFromList = (String) (modeList.getItemAtPosition(position)); dialog.dismiss(); if (selectedFromList != null) { FragmentManager fm = getSupportFragmentManager(); SearchFragment sf = (SearchFragment) fm.findFragmentById(R.id.search_fragment); sf.setSearchField(selectedFromList); } } }); dialog.show(); } } }
From source file:org.telegram.ui.LanguageSelectActivity.java
@Override public View createView(Context context) { searching = false;// w ww. j av a2 s. c om searchWas = false; actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("Language", R.string.Language)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); ActionBarMenu menu = actionBar.createMenu(); ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true) .setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { searching = true; } @Override public void onSearchCollapse() { search(null); searching = false; searchWas = false; if (listView != null) { emptyTextView.setVisibility(View.GONE); listView.setAdapter(listAdapter); } } @Override public void onTextChanged(EditText editText) { String text = editText.getText().toString(); search(text); if (text.length() != 0) { searchWas = true; if (listView != null) { listView.setAdapter(searchListViewAdapter); } } } }); item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); listAdapter = new ListAdapter(context); searchListViewAdapter = new SearchAdapter(context); fragmentView = new FrameLayout(context); fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); LinearLayout emptyTextLayout = new LinearLayout(context); emptyTextLayout.setVisibility(View.INVISIBLE); emptyTextLayout.setOrientation(LinearLayout.VERTICAL); ((FrameLayout) fragmentView).addView(emptyTextLayout); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; emptyTextLayout.setLayoutParams(layoutParams); emptyTextLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); emptyTextView = new TextView(context); emptyTextView.setTextColor(0xff808080); emptyTextView.setTextSize(20); emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult)); emptyTextLayout.addView(emptyTextView); LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams(); layoutParams1.width = LayoutHelper.MATCH_PARENT; layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.weight = 0.5f; emptyTextView.setLayoutParams(layoutParams1); FrameLayout frameLayout = new FrameLayout(context); emptyTextLayout.addView(frameLayout); layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); layoutParams1.width = LayoutHelper.MATCH_PARENT; layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.weight = 0.5f; frameLayout.setLayoutParams(layoutParams1); listView = new ListView(context); listView.setEmptyView(emptyTextLayout); listView.setVerticalScrollBarEnabled(false); listView.setDivider(null); listView.setDividerHeight(0); listView.setAdapter(listAdapter); ((FrameLayout) fragmentView).addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { LocaleController.LocaleInfo localeInfo = null; if (searching && searchWas) { if (i >= 0 && i < searchResult.size()) { localeInfo = searchResult.get(i); } } else { if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) { localeInfo = LocaleController.getInstance().sortedLanguages.get(i); } } if (localeInfo != null) { LocaleController.getInstance().applyLanguage(localeInfo, true); parentLayout.rebuildAllFragmentViews(false); } finishFragment(); } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) { LocaleController.LocaleInfo localeInfo = null; if (searching && searchWas) { if (i >= 0 && i < searchResult.size()) { localeInfo = searchResult.get(i); } } else { if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) { localeInfo = LocaleController.getInstance().sortedLanguages.get(i); } } if (localeInfo == null || localeInfo.pathToFile == null || getParentActivity() == null) { return false; } final LocaleController.LocaleInfo finalLocaleInfo = localeInfo; AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("DeleteLocalization", R.string.DeleteLocalization)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (LocaleController.getInstance().deleteLanguage(finalLocaleInfo)) { if (searchResult != null) { searchResult.remove(finalLocaleInfo); } if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } if (searchListViewAdapter != null) { searchListViewAdapter.notifyDataSetChanged(); } } } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); return true; } }); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) { AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); return fragmentView; }
From source file:com.googlecode.networklog.LogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { MyLog.d("[LogFragment] onCreateView"); LinearLayout layout = new LinearLayout(getActivity().getApplicationContext()); layout.setOrientation(LinearLayout.VERTICAL); ListView listView = new ListView(getActivity().getApplicationContext()); listView.setAdapter(adapter);/*from w w w. j a v a2 s . c o m*/ listView.setTextFilterEnabled(true); listView.setFastScrollEnabled(true); listView.setSmoothScrollbarEnabled(false); listView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL); listView.setStackFromBottom(true); listView.setOnItemClickListener(new CustomOnItemClickListener()); layout.addView(listView); registerForContextMenu(listView); startUpdater(); return layout; }
From source file:it.unibs.sandroide.lib.beacon.ui.BeaconTagActivity.java
private void renderListViews() { LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.TOP);//from w ww.ja v a 2 s. c o m lvBeacons = new ListView(this); lvBeacons.setId(LISTBEACONS_VIEW_ID); lvBeacons.setDivider(null); lvBeacons.setDividerHeight(0); lvTags = new ListView(this); lvTags.setId(LISTTAGS_VIEW_ID); lvTags.setVisibility(View.INVISIBLE); lvTags.setDivider(null); lvTags.setDividerHeight(0); layout.addView(lvBeacons, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1)); layout.addView(lvTags, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1)); setContentView(layout); }
From source file:com.sanbo.moveonapp.TabsActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { loaded = savedInstanceState.getBoolean("loaded", false); showLang = savedInstanceState.getBoolean("showLang", false); showDialog = savedInstanceState.getBoolean("showDialog", false); }//from w ww .ja v a2 s . c o m try { LocationSynchronizer mLocationSynchronizer = LocationSynchronizer .getInstance((SynchronizableActivity) getSynchronizableActivity()); myLocation = mLocationSynchronizer.getLocation(); if (myLocation == null) MoveOnCroutonStyle.croutonAlert(this, R.string.error_location_NETWORK); } catch (Exception e) { Log.e(Config.LOGTAG, "TabsActivity.onResume getting show Defaults from SharedPreferences"); } //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.activity_tabs); // Show the Up button in the action bar: ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); context = this; //ProgressBar while is filling the list myProgressBar = (ProgressBar) findViewById(R.id.progress); isEmpty = (TextView) findViewById(R.id.empty); //Vector of pages Vector<View> pages = new Vector<View>(); //List Message showing description on click show Exp List listviewMessage = new ListView(context); listviewMessage.setDivider(context.getResources().getDrawable(R.drawable.line)); listviewMessage.setDividerHeight(1); //List Message showing complete description, onClickItem listviewMessageExp = new ListView(context); listviewMessageExp.setDivider(context.getResources().getDrawable(R.drawable.line)); listviewMessageExp.setDividerHeight(1); // two pages pages.add(listviewMessage); pages.add(listviewMessageExp); // our adapter for pager vp = (ViewPager) findViewById(R.id.pager); CustomPagerAdapter adapter = new CustomPagerAdapter(context, pages); vp.setAdapter(adapter); //Execute asyntask (we can send string array) new BackgroundTask().execute("SOMETHING"); //mlistAdapter = new ListViewAdapterMessage(context, myPublic.getListAllMessages()); //listviewMessageExp.setAdapter(mlistAdapter); //listviewMessage.setAdapter(mlistAdapter); // click event for each row of the list listviewMessage.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // arg2 = the id of the item in our view (List/Grid) that we clicked // arg3 = the id of the item that we have clicked // if we didn't assign any id for the Object (Book) the arg3 value is 0 // That means if we comment, aBookDetail.setBookIsbn(i); arg3 value become 0 if (Config.DEBUG) Toast.makeText(getApplicationContext(), "You clicked on position : " + arg2 + " and id : " + arg3, Toast.LENGTH_LONG).show(); TextView c = (TextView) arg1.findViewById(R.id.textDescription); int changeit = (View.VISIBLE != c.getVisibility()) ? View.VISIBLE : View.GONE; c.setVisibility(changeit); listviewMessage.setSelection(arg2); } }); // Objects to change on the fly this.rl = (RelativeLayout) findViewById(R.id.rl_tabs); this.txt_hello = (TextView) findViewById(R.id.tabsMessage); this.txt_version = (TextView) findViewById(R.id.tabsVersionNumber); this.txt_textList = (TextView) findViewById(R.id.textList); this.img_icon = (ImageView) findViewById(R.id.tabsImageIcon); this.button1 = (Button) findViewById(R.id.button1); this.button2 = (Button) findViewById(R.id.button2); this.button3 = (Button) findViewById(R.id.button3); this.button4 = (Button) findViewById(R.id.button4); this.button5 = (Button) findViewById(R.id.button5); loadLocale(); //Configuration Language if (loaded) { showButtons(); } else { // instance of timer and myTimerTask txt_hello.setVisibility(View.VISIBLE); txt_hello.setText(R.string.dataBaseLoaded); txt_version.setVisibility(View.VISIBLE); img_icon.setVisibility(View.VISIBLE); timer = new Timer(); myTimerTask = new MyTimerTask(); timer.schedule(myTimerTask, 2000); } ((Button) findViewById(R.id.button1)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Open activity of routes not impelented on v1.0 if (Config.DEBUG) Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.routesNotImplemented), Toast.LENGTH_SHORT).show(); MoveOnCroutonStyle.croutonWarn(TabsActivity.this, R.string.routesNotImplemented); //MoveOnCroutonStyle.croutonAlert(TabsActivity.this, R.string.error_loadingDB); //MoveOnCroutonStyle.croutonFly(TabsActivity.this, R.string.error_loadingDB); //MoveOnCroutonStyle.croutonInfo(TabsActivity.this, R.string.error_loadingDB); //MoveOnCroutonStyle.croutonConfirm(TabsActivity.this, R.string.error_loadingDB); //Initialize route Activity //startActivity(new Intent(context, ItineraryActivity.class)); } }); ((Button) findViewById(R.id.button2)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Open tabs User showing LINES if (Config.DEBUG) Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.lines), Toast.LENGTH_SHORT).show(); savingState.setTabInit(AppConstants.TAB_A); //Open tabs showwing LINES startActivity(new Intent(context, AppMainTabActivity.class)); } }); ((Button) findViewById(R.id.button3)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Open tabs User showing STATIONS if (Config.DEBUG) Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.stations), Toast.LENGTH_SHORT).show(); savingState.setTabInit(AppConstants.TAB_B); //Open tabs showwing LINES startActivity(new Intent(context, AppMainTabActivity.class)); } }); ((Button) findViewById(R.id.button4)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Open tabs User showing FAVORITES if (Config.DEBUG) Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.favourits), Toast.LENGTH_SHORT).show(); savingState.setTabInit(AppConstants.TAB_D); //Open tabs showwing LINES startActivity(new Intent(context, AppMainTabActivity.class)); } }); ((Button) findViewById(R.id.button5)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Open tabs User showing NEARBY STATION if (Config.DEBUG) Toast.makeText(v.getContext(), v.getContext().getResources().getString(R.string.nearbystations), Toast.LENGTH_SHORT).show(); savingState.setTabInit(AppConstants.TAB_C); //Open tabs showwing LINES startActivity(new Intent(context, AppMainTabActivity.class)); } }); if (showLang) menuLanguage(); if (showDialog) showDialog(); }
From source file:org.quantumbadger.redreader.activities.AlbumListingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PrefsUtility.applyTheme(this); OptionsMenuUtility.fixActionBar(AlbumListingActivity.this, getString(R.string.imgur_album)); if (getActionBar() != null) { getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); }/*from w w w . jav a 2s .c o m*/ final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences) && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT; if (solidblack) getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK)); final Intent intent = getIntent(); mUrl = intent.getDataString(); if (mUrl == null) { finish(); return; } final Matcher matchImgur = LinkHandler.imgurAlbumPattern.matcher(mUrl); final String albumId; if (matchImgur.find()) { albumId = matchImgur.group(2); } else { Log.e("AlbumListingActivity", "URL match failed"); revertToWeb(); return; } Log.i("AlbumListingActivity", "Loading URL " + mUrl + ", album id " + albumId); final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); progressBar.setIndeterminate(true); final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(progressBar); ImgurAPI.getAlbumInfo(this, albumId, Constants.Priority.IMAGE_VIEW, 0, new GetAlbumInfoListener() { @Override public void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status, final String readableMessage) { Log.e("AlbumListingActivity", "getAlbumInfo call failed: " + type); if (status != null) Log.e("AlbumListingActivity", "status was: " + status.toString()); if (t != null) Log.e("AlbumListingActivity", "exception was: ", t); // It might be a single image, not an album if (status == null) { revertToWeb(); return; } ImgurAPI.getImageInfo(AlbumListingActivity.this, albumId, Constants.Priority.IMAGE_VIEW, 0, new GetImageInfoListener() { @Override public void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status, final String readableMessage) { Log.e("AlbumListingActivity", "Image info request also failed: " + type); revertToWeb(); } @Override public void onSuccess(final ImageInfo info) { Log.i("AlbumListingActivity", "Link was actually an image."); LinkHandler.onLinkClicked(AlbumListingActivity.this, info.urlOriginal); finish(); } @Override public void onNotAnImage() { Log.i("AlbumListingActivity", "Not an image either"); revertToWeb(); } }); } @Override public void onSuccess(final ImgurAPI.AlbumInfo info) { Log.i("AlbumListingActivity", "Got album, " + info.images.size() + " image(s)"); AndroidApi.UI_THREAD_HANDLER.post(new Runnable() { @Override public void run() { if (info.title != null && !info.title.trim().isEmpty()) { OptionsMenuUtility.fixActionBar(AlbumListingActivity.this, getString(R.string.imgur_album) + ": " + info.title); } layout.removeAllViews(); final ListView listView = new ListView(AlbumListingActivity.this); listView.setAdapter(new AlbumAdapter(info)); layout.addView(listView); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { LinkHandler.onLinkClicked(AlbumListingActivity.this, info.images.get(position).urlOriginal, false, null, info, position); } }); } }); } }); setContentView(layout); }