List of usage examples for android.widget AdapterView getAdapter
public abstract T getAdapter();
From source file:com.apotheosis.acceleration.monitor.MainMenuActivity.java
private void setUpListView() { ListView lv = (ListView) findViewById(R.id.fileList); List<String> fileNames = FileUtilities.getFileList(); if (fileNames != null) { FileListAdapter listAdapter = new FileListAdapter(this); lv.setAdapter(listAdapter);// w w w .j a va 2 s. c o m lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.mainDrawerLayout); boolean isDrawerOpen = drawerLayout.isDrawerOpen(findViewById(R.id.side_drawer)); if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.ACCELERATION, MainMenuActivity.this, parent.getAdapter().getItem(position).toString()).execute((Void[]) null); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final String fileName = parent.getAdapter().getItem(position).toString(); final AlertDialog.Builder optionsMenu = new AlertDialog.Builder(MainMenuActivity.this); optionsMenu.setItems(new String[] { "Open Acceleration Graph", "Open Raw Data", "Share Data", "Delete Data", "Cancel" }, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.mainDrawerLayout); boolean isDrawerOpen = drawerLayout .isDrawerOpen(findViewById(R.id.side_drawer)); Intent i; Tracker tracker; switch (which) { case 0: dialog.dismiss(); if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.ACCELERATION, MainMenuActivity.this, fileName).execute((Void[]) null); break; case 1: if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.RAW_DATA, MainMenuActivity.this, fileName).execute((Void[]) null); break; case 2: if (isDrawerOpen) drawerLayout.closeDrawers(); tracker = AnalyticsTrackers.getInstance().get(AnalyticsTrackers.Target.APP); tracker.send(new HitBuilders.EventBuilder().setCategory("Data Function") .setAction("Share Data").build()); i = new Intent(Intent.ACTION_SEND); i.setType("text/xml"); i.putExtra(Intent.EXTRA_SUBJECT, "Sending " + fileName + "as attachment"); i.putExtra(Intent.EXTRA_TEXT, fileName + "is attached."); File f = new File(FileUtilities.path + fileName + ".csv"); i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f)); startActivity(Intent.createChooser(i, "Choose an application...")); break; case 3: final AlertDialog.Builder confirmDelete = new AlertDialog.Builder( MainMenuActivity.this); confirmDelete .setMessage("Are you sure you want to delete " + fileName + "?"); confirmDelete.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { File f = new File(FileUtilities.path + fileName + ".csv"); Log.d("DELETION_SUCESS", String.valueOf(f.delete())); setUpListView(); } }); confirmDelete.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); confirmDelete.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); } }); confirmDelete.show(); break; } } }); optionsMenu.show(); return true; } }); } }
From source file:uk.org.crimetalk.fragments.SearchFragment.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final ArrayList<ArticleListHelper> articleListHelperList = getArguments() .getParcelableArrayList(SearchActivity.ARG_ARTICLE_LIST_HELPER_LIST); // If should load in a local browser, load in a local browser if (articleListHelperList.get(0).getFragmentIdentifier() == ArticleListHelper.PRESSCUTTINGS_FRAGMENT || PreferenceUtils.getLoadInBrowser(getActivity())) { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(((ArticleListItem) parent.getAdapter().getItem(position)).getLink())); startActivity(intent);//from w ww . j a v a 2 s.c o m return; } // Otherwise, load in a native content viewer final Intent intent = new Intent(getActivity(), ArticleContentActivity.class); intent.putExtra(ArticleContentActivity.ARG_LIST_ITEM, (ArticleListItem) parent.getAdapter().getItem(position)); startActivity(intent); }
From source file:com.gh4a.fragment.EventListFragment.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Event event = (Event) adapterView.getAdapter().getItem(position); Gh4Application context = ((BaseSherlockFragmentActivity) getActivity()).getApplicationContext(); if (event == null || event.getPayload() == null) { return;/*from w ww . j a v a 2 s . com*/ } //if payload is a base class, return void. Think that it is an old event which not supported //by API v3. if (event.getPayload().getClass().getSimpleName().equals("EventPayload")) { return; } String eventType = event.getType(); EventRepository eventRepo = event.getRepo(); String[] repoNamePart = eventRepo.getName().split("/"); String repoOwner = ""; String repoName = ""; if (repoNamePart.length == 2) { repoOwner = repoNamePart[0]; repoName = repoNamePart[1]; } String repoUrl = eventRepo.getUrl(); /** PushEvent */ if (Event.TYPE_PUSH.equals(eventType)) { if (eventRepo != null) { PushPayload payload = (PushPayload) event.getPayload(); List<Commit> commits = payload.getCommits(); // if commit > 1, then show compare activity if (commits != null) { if (commits.size() > 1) { Intent intent = new Intent().setClass(context, CompareActivity.class); intent.putExtra(Constants.Repository.REPO_OWNER, repoOwner); intent.putExtra(Constants.Repository.REPO_NAME, repoName); intent.putExtra(Constants.Repository.HEAD, payload.getHead()); intent.putExtra(Constants.Repository.BASE, payload.getBefore()); startActivity(intent); } // only 1 commit, then show the commit details else if (commits.size() == 1) { context.openCommitInfoActivity(getSherlockActivity(), repoOwner, repoName, payload.getCommits().get(0).getSha(), 0); } else { context.openRepositoryInfoActivity(getSherlockActivity(), repoOwner, repoName, 0); } } else { context.openRepositoryInfoActivity(getSherlockActivity(), repoOwner, repoName, 0); } } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** IssueEvent */ else if (Event.TYPE_ISSUES.equals(eventType)) { if (eventRepo != null) { IssuesPayload payload = (IssuesPayload) event.getPayload(); context.openIssueActivity(getSherlockActivity(), repoOwner, repoName, payload.getIssue().getNumber()); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** WatchEvent */ else if (Event.TYPE_WATCH.equals(eventType)) { if (eventRepo != null) { context.openRepositoryInfoActivity(getSherlockActivity(), repoOwner, repoName, 0); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** CreateEvent */ else if (Event.TYPE_CREATE.equals(eventType)) { if (eventRepo != null) { context.openRepositoryInfoActivity(this.getSherlockActivity(), repoOwner, repoName, 0); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** PullRequestEvent */ else if (Event.TYPE_PULL_REQUEST.equals(eventType)) { if (eventRepo != null) { PullRequestPayload payload = (PullRequestPayload) event.getPayload(); int pullRequestNumber = payload.getNumber(); context.openPullRequestActivity(getSherlockActivity(), repoOwner, repoName, pullRequestNumber); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** FollowEvent */ else if (Event.TYPE_FOLLOW.equals(eventType)) { FollowPayload payload = (FollowPayload) event.getPayload(); if (payload.getTarget() != null) { context.openUserInfoActivity(getSherlockActivity(), payload.getTarget().getLogin(), null); } } /** CommitCommentEvent */ else if (Event.TYPE_COMMIT_COMMENT.equals(eventType)) { if (eventRepo != null) { CommitCommentPayload payload = (CommitCommentPayload) event.getPayload(); context.openCommitInfoActivity(getSherlockActivity(), repoOwner, repoName, payload.getComment().getCommitId(), 0); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** DeleteEvent */ else if (Event.TYPE_DELETE.equals(eventType)) { if (eventRepo != null) { context.openRepositoryInfoActivity(getSherlockActivity(), repoOwner, repoName, 0); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** DownloadEvent */ else if (Event.TYPE_DOWNLOAD.equals(eventType)) { if (eventRepo != null) { DownloadPayload payload = (DownloadPayload) event.getPayload(); context.openBrowser(getSherlockActivity(), payload.getDownload().getHtmlUrl()); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** ForkEvent */ else if (Event.TYPE_FORK.equals(eventType)) { ForkPayload payload = (ForkPayload) event.getPayload(); Repository forkee = payload.getForkee(); if (forkee != null) { context.openRepositoryInfoActivity(getSherlockActivity(), forkee); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** ForkEvent */ else if (Event.TYPE_FORK_APPLY.equals(eventType)) { if (eventRepo != null) { ForkApplyPayload payload = (ForkApplyPayload) event.getPayload(); context.openRepositoryInfoActivity(getSherlockActivity(), repoOwner, repoName, 0); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** GollumEvent */ else if (Event.TYPE_GOLLUM.equals(eventType)) { Intent intent = new Intent().setClass(getSherlockActivity(), WikiListActivity.class); intent.putExtra(Constants.Repository.REPO_OWNER, repoOwner); intent.putExtra(Constants.Repository.REPO_NAME, repoName); startActivity(intent); } /** PublicEvent */ else if (Event.TYPE_PUBLIC.equals(eventType)) { if (eventRepo != null) { context.openRepositoryInfoActivity(getSherlockActivity(), repoOwner, repoName, 0); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** MemberEvent */ else if (Event.TYPE_MEMBER.equals(eventType)) { if (eventRepo != null) { MemberPayload payload = (MemberPayload) event.getPayload(); context.openRepositoryInfoActivity(getSherlockActivity(), repoOwner, repoName, 0); } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** Gist Event **/ else if (Event.TYPE_GIST.equals(eventType)) { GistPayload payload = (GistPayload) event.getPayload(); String login = event.getActor().getLogin(); if (StringUtils.isBlank(login) && payload.getGist() != null && payload.getGist().getUser() != null) { login = payload.getGist().getUser().getLogin(); } if (!StringUtils.isBlank(login)) { context.openGistActivity(getSherlockActivity(), login, payload.getGist().getId(), 0); } } /** IssueCommentEvent */ else if (Event.TYPE_ISSUE_COMMENT.equals(eventType)) { if (eventRepo != null) { IssueCommentPayload payload = (IssueCommentPayload) event.getPayload(); if (payload.getIssue() != null) { if (payload.getIssue().getPullRequest() != null) { if (payload.getIssue().getPullRequest().getHtmlUrl() != null) { context.openPullRequestActivity(getSherlockActivity(), repoOwner, repoName, payload.getIssue().getNumber()); } else { context.openIssueActivity(getSherlockActivity(), repoOwner, repoName, payload.getIssue().getNumber(), payload.getIssue().getState()); } } else { context.openIssueActivity(getSherlockActivity(), repoOwner, repoName, payload.getIssue().getNumber(), payload.getIssue().getState()); } } } else { context.notFoundMessage(getSherlockActivity(), R.plurals.repository); } } /** PullRequestReviewComment */ else if (Event.TYPE_PULL_REQUEST_REVIEW_COMMENT.equals(eventType)) { PullRequestReviewCommentPayload payload = (PullRequestReviewCommentPayload) event.getPayload(); context.openCommitInfoActivity(getSherlockActivity(), repoOwner, repoName, payload.getComment().getCommitId(), 0); } }
From source file:com.zhongyun.viewer.cameralist.CameraListActivity.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { CameraInfo cameraInfo = (CameraInfo) parent.getAdapter().getItem(position); if (cameraInfo.getIsOnline()) { Intent intent = new Intent(this, WatchActivity.class); intent.putExtra(Constants.INTENT_CID, cameraInfo.getCid()); intent.putExtra(Constants.INTENT_CAMERA_NAME, cameraInfo.getCameraName()); startActivity(intent);// w w w . j a v a 2 s .c o m } else { Toast.makeText(this, R.string.camera_offline, Toast.LENGTH_LONG); } }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display dialog to allow user to add an app to a row. The user can add the * app to an existing row or a new row.// w w w . j av a2 s .c o m * * @param context * @param applications */ public static void displayAddApps(final Launcher context, final ArrayList<ApplicationInfo> applications) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.add_apps_grid); final EditText nameEditText = (EditText) dialog.findViewById(R.id.rowName); final RadioButton currentRadioButton = (RadioButton) dialog.findViewById(R.id.currentRadio); currentRadioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // hide the row name edit field if the current row radio button // is selected nameEditText.setVisibility(View.GONE); } }); final RadioButton newRadioButton = (RadioButton) dialog.findViewById(R.id.newRadio); newRadioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // show the row name edit field if the new radio button is // selected nameEditText.setVisibility(View.VISIBLE); nameEditText.requestFocus(); } }); final GridView gridView = (GridView) dialog.findViewById(R.id.grid); gridView.setAdapter(new AllItemAdapter(context, getApplications(context, applications, true))); gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // if the new row radio button is selected, the user must enter // a name for the new row String name = nameEditText.getText().toString().trim(); if (newRadioButton.isChecked() && name.length() == 0) { nameEditText.requestFocus(); displayAlert(context, context.getString(R.string.dialog_new_row_name_alert)); return; } ItemInfo itemInfo = (ItemInfo) parent.getAdapter().getItem(position); boolean currentRow = !newRadioButton.isChecked(); context.addItem(itemInfo, currentRow ? null : name); context.showCover(false); dialog.dismiss(); if (currentRow) { Analytics.logEvent(Analytics.DIALOG_ADD_APP); } else { Analytics.logEvent(Analytics.ADD_APP_WITH_ROW); } } }); gridView.setDrawingCacheEnabled(true); gridView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_ADD_APP); }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display dialog to the user for the Spotlight web apps: * https://www.google.com/tv/spotlight-gallery.html Allow the user to add a * web app to an existing row or a new row. * /*from w ww.j a va 2 s. co m*/ * @param context */ public static void displayAddSpotlight(final Launcher context) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.add_apps_grid); final EditText nameEditText = (EditText) dialog.findViewById(R.id.rowName); final RadioButton currentRadioButton = (RadioButton) dialog.findViewById(R.id.currentRadio); currentRadioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // hide the row name edit field if the current row radio button // is selected nameEditText.setVisibility(View.GONE); } }); final RadioButton newRadioButton = (RadioButton) dialog.findViewById(R.id.newRadio); newRadioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // show the row name edit field if the new radio button is // selected nameEditText.setVisibility(View.VISIBLE); nameEditText.requestFocus(); } }); final GridView gridView = (GridView) dialog.findViewById(R.id.grid); final ArrayList<SpotlightInfo> spotlights = SpotlightTable.getAllSpotlights(context); gridView.setAdapter(new AllSpotlightAdapter(context, spotlights)); gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // if the new row radio button is selected, the user must enter // a name for the new row String name = nameEditText.getText().toString().trim(); if (newRadioButton.isChecked() && name.length() == 0) { nameEditText.requestFocus(); displayAlert(context, context.getString(R.string.dialog_new_row_name_alert)); return; } ItemInfo itemInfo = (ItemInfo) parent.getAdapter().getItem(position); boolean currentRow = !newRadioButton.isChecked(); context.addItem(itemInfo, currentRow ? null : name); context.showCover(false); dialog.dismiss(); if (currentRow) { Analytics.logEvent(Analytics.ADD_SPOTLIGHT_WEB_APP); } else { Analytics.logEvent(Analytics.ADD_SPOTLIGHT_WEB_APP_WITH_ROW); } } }); gridView.setDrawingCacheEnabled(true); gridView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_ADD_SPOTLIGHT_WEB_APP); }
From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java
private View makeTeamView(Team team, ViewGroup root) { ViewGroup teamView = (ViewGroup) getLayoutInflater().inflate(R.layout.card_team, root, false); TextView teamName = (TextView) teamView.findViewById(R.id.card_team_name); BezelImageView teamLogo = (BezelImageView) teamView.findViewById(R.id.card_team_logo); ExpandableHeightGridView teamContent = (ExpandableHeightGridView) teamView .findViewById(R.id.card_team_gridview); final Uri teamUri = Uri.parse(team.teamUrl); (teamView.findViewById(R.id.card_team_link)).setOnClickListener(new View.OnClickListener() { @Override/*from ww w. ja va 2 s. co m*/ public void onClick(View v) { startActivity(new Intent(Intent.ACTION_VIEW, teamUri)); } }); TextView bettingOdds = (TextView) teamView.findViewById(R.id.card_team_gosubet); if (team.gosubetTie != null) { teamView.findViewById(R.id.card_team_gb_windraw).setVisibility(View.VISIBLE); bettingOdds.setText(team.gosubetWin + "\n" + team.gosubetTie); } else { bettingOdds.setText(team.gosubetWin); } if (team.recPerf != null) { RecentPerfAdapter mAdapter = new RecentPerfAdapter(this, R.layout.grid_recent_perf, team.recPerf); teamContent.setExpanded(true); teamName.setText(team.name); Picasso.with(this).load(team.flagUrl).into(teamLogo); teamContent.setAdapter(mAdapter); teamContent.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RecentMatch match = (RecentMatch) parent.getAdapter().getItem(position); final Uri uri = Uri.parse(match.matchUrl); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }); } else if (team.players != null) { TextView contentDescriptor = (TextView) teamView.findViewById(R.id.card_team_content_descriptor); PlayerAdapter mAdapter = new PlayerAdapter(this, R.layout.grid_player, team.players); contentDescriptor.setText("Players:"); teamContent.setExpanded(true); teamContent.setColumnWidth(Math.round(UIUtils.dpToPx(getResources().getDisplayMetrics(), 120f))); teamName.setText(team.name); Picasso.with(this).load(team.flagUrl).into(teamLogo); teamContent.setAdapter(mAdapter); teamContent.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Player mPlayer = (Player) parent.getAdapter().getItem(position); final Uri uri = Uri.parse(mPlayer.profilePageUrl); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }); } return teamView; }
From source file:com.gimranov.zandy.app.ItemActivity.java
/** * Called when the activity is first created. *///from w w w. j a va2 s . c om @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String persistedSort = Persistence.read(SORT_CHOICE); if (persistedSort != null) sortBy = persistedSort; db = new Database(this); setContentView(R.layout.items); Intent intent = getIntent(); collectionKey = intent.getStringExtra("com.gimranov.zandy.app.collectionKey"); ItemCollection coll = ItemCollection.load(collectionKey, db); APIRequest req; if (coll != null) { req = APIRequest.fetchItems(coll, false, new ServerCredentials(this)); } else { req = APIRequest.fetchItems(false, new ServerCredentials(this)); } prepareAdapter(); ItemAdapter adapter = (ItemAdapter) getListAdapter(); Cursor cur = adapter.getCursor(); if (intent.getBooleanExtra("com.gimranov.zandy.app.rerequest", false) || cur == null || cur.getCount() == 0) { if (!ServerCredentials.check(getBaseContext())) { Toast.makeText(getBaseContext(), getResources().getString(R.string.sync_log_in_first), Toast.LENGTH_SHORT).show(); return; } Toast.makeText(this, getResources().getString(R.string.collection_empty), Toast.LENGTH_SHORT).show(); Log.d(TAG, "Running a request to populate missing items"); ZoteroAPITask task = new ZoteroAPITask(this); req.setHandler(mEvent); task.execute(req); } ListView lv = getListView(); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // If we have a click on an item, do something... ItemAdapter adapter = (ItemAdapter) parent.getAdapter(); Cursor cur = adapter.getCursor(); // Place the cursor at the selected item if (cur.moveToPosition(position)) { // and load an activity for the item Item item = Item.load(cur); Log.d(TAG, "Loading item data with key: " + item.getKey()); // We create and issue a specified intent with the necessary data Intent i = new Intent(getBaseContext(), ItemDataActivity.class); i.putExtra("com.gimranov.zandy.app.itemKey", item.getKey()); i.putExtra("com.gimranov.zandy.app.itemDbId", item.dbId); startActivity(i); } else { // failed to move cursor-- show a toast TextView tvTitle = (TextView) view.findViewById(R.id.item_title); Toast.makeText(getApplicationContext(), getResources().getString(R.string.cant_open_item, tvTitle.getText()), Toast.LENGTH_SHORT).show(); } } }); }
From source file:ru.adios.budgeter.widgets.DataTableLayout.java
private void loadDataAndPopulateTable() { new AsyncTask<DataStore, Void, Integer>() { @Override//from w w w . j a v a2 s . co m protected Integer doInBackground(DataStore... params) { return params[0].count(); } @Override protected void onPostExecute(Integer c) { count = c; if (c == 0) { insertNoDataRow(); tablePopulated = true; if (listener.isPresent()) { listener.get().accept(DataTableLayout.this); } invalidate(); return; } if (currentPage == 0) { turnToPage(1, false); } if (c > pageSize) { final Context context = getContext(); if (tableName.isPresent()) { pageSizeSpinner = new Spinner(context, Spinner.MODE_DROPDOWN); pageSizeSpinner.setMinimumWidth(UiUtils.dpAsPixels(context, 70)); pageSizeSpinner.setId(ElementsIdProvider.getNextId()); final List<Integer> contents = getPageSpinnerContents(); spinnerContents = Optional.of(contents); pageSizeSpinner.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, android.R.id.text1, contents)); pageSizeSpinner.setSelection(contents.indexOf(pageSize)); pageSizeSpinner.setLayoutParams(new LinearLayout.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 2f)); pageSizeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { setPageSize((Integer) parent.getAdapter().getItem(position)); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); pageSizeSpinner.setVisibility(VISIBLE); if (!titleView.isPresent()) { addTitleRowWithSeparator(context, 10f, 8f); } else { titleView.get().setWeightSum(10f); titleView.get().getChildAt(0).setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 8f)); } titleView.get().addView(pageSizeSpinner, 0); } final TableRow.LayoutParams fp = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 1f); fp.span = itemsPerInnerRow; footer.setLayoutParams(fp); footer.setVisibility(VISIBLE); populateFooter(); } loadTableProcedures(); } }.execute(dataStore); }
From source file:tv.acfun.a63.CommentsActivity.java
private void initCommentsBar() { mCommentBar = findViewById(R.id.comments_bar); if (ActionBarUtil.hasSB() && getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { RelativeLayout.LayoutParams params = (LayoutParams) mCommentBar.getLayoutParams(); params.bottomMargin = getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); mCommentBar.setLayoutParams(params); }//from w w w . j av a 2s .c o m mBtnSend = (ImageButton) findViewById(R.id.comments_send_btn); mCommentText = (EditText) findViewById(R.id.comments_edit); mBtnEmotion = findViewById(R.id.comments_emotion_btn); mEmotionGrid = (GridView) findViewById(R.id.emotions); mBtnSend.setOnClickListener(this); mBtnEmotion.setOnClickListener(this); mEmotionGrid.setAdapter(mEmotionAdapter); mEmotionGrid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int index = mCommentText.getSelectionEnd(); Editable text = mCommentText.getText(); String emotion = parent.getItemAtPosition(position).toString(); text.insert(index, emotion); EmotionView v = (EmotionView) parent.getAdapter().getView(position, null, null); Drawable drawable = TextViewUtils.convertViewToDrawable(v); drawable.setBounds(0, 0, drawable.getIntrinsicWidth() / 2, drawable.getIntrinsicHeight() / 2); text.setSpan(new ImageSpan(drawable), index, index + emotion.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } }); }