List of usage examples for android.widget ListView addHeaderView
public void addHeaderView(View v, Object data, boolean isSelectable)
From source file:com.abcvoipsip.ui.messages.ConversationsListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { View v = inflater.inflate(R.layout.call_log_fragment, container, false); ListView lv = (ListView) v.findViewById(android.R.id.list); // Add header ViewGroup headerView = (ViewGroup) inflater.inflate(R.layout.conversation_list_item, lv, false); ((TextView) headerView.findViewById(R.id.from)).setText(R.string.new_message); ((TextView) headerView.findViewById(R.id.subject)).setText(R.string.create_new_message); headerView.findViewById(R.id.quick_contact_photo).setVisibility(View.GONE); lv.addHeaderView(headerView, null, true); TextView tv = (TextView) v.findViewById(android.R.id.empty); tv.setText(R.string.status_none);//w w w . j a va 2s . com return v; }
From source file:com.meiste.greg.ptw.tab.Standings.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { mSetupNeeded = GAE.isAccountSetupNeeded(getActivity()); mChanged = false;/*w w w .j ava 2 s . co m*/ mAccountSetupTime = Util.getAccountSetupTime(getActivity()); setRetainInstance(true); final IntentFilter filter = new IntentFilter(PTW.INTENT_ACTION_STANDINGS); getActivity().registerReceiver(mBroadcastReceiver, filter); if (mSetupNeeded) return Util.getAccountSetupView(getActivity(), inflater, container); else if (mFailedConnect) { mFailedConnect = false; final View v = inflater.inflate(R.layout.no_connection, container, false); final Button retry = (Button) v.findViewById(R.id.retry); retry.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { mChanged = true; notifyChanged(); } }); return v; } else if (!isStandingsPresent() || mConnecting) { if (!mConnecting) { mConnecting = true; GAE.getInstance(getActivity()).getPage(this, "standings"); } return inflater.inflate(R.layout.connecting, container, false); } final View v = inflater.inflate(R.layout.list, container, false); mSwipeRefreshWidget = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_widget); mSwipeRefreshWidget.setOnRefreshListener(this); mSwipeRefreshWidget.setColorSchemeResources(R.color.refresh1, R.color.refresh2, R.color.refresh3, R.color.refresh4); final ListView lv = (ListView) v.findViewById(R.id.content); final View header = inflater.inflate(R.layout.standings_header, lv, false); mAdapter = new PlayerAdapter(getActivity()); mAfterRace = (TextView) header.findViewById(R.id.after); mAfterRace.setText(getRaceAfterText(getActivity())); lv.addHeaderView(header, null, false); final View footer = inflater.inflate(R.layout.standings_footer, lv, false); mFooter = (TextView) footer.findViewById(R.id.standings_footer); mFooter.setText(getFooterText(getActivity())); lv.addFooterView(footer, null, false); lv.setAdapter(mAdapter); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View v, final int pos, final long id) { final Player player = (Player) parent.getItemAtPosition(pos); if (mAdapter.isSelf(player)) { Util.log("Opening privacy dialog"); if (mPrivacyDialog == null) { mPrivacyDialog = new PrivacyDialog(getActivity(), Standings.this); } mPrivacyDialog.show(mAdapter.getPlayerName()); } else { Util.log("Opening friend action dialog"); if (mFriendActionDialog == null) { mFriendActionDialog = new FriendActionDialog(getActivity(), Standings.this); } mFriendActionDialog.show(player); } } }); final ImageView iv = (ImageView) v.findViewById(R.id.add_friend); iv.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if ((NfcAdapter.getDefaultAdapter(getActivity()) != null) && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) && mAdapter.getPlayer().isIdentifiable() && Gcm.isRegistered(getActivity())) { Util.log("NFC available. Need to ask user add method."); if (mFriendMethodDialog == null) { mFriendMethodDialog = new FriendMethodDialog(getActivity(), Standings.this); } mFriendMethodDialog.reset(); mFriendMethodDialog.show(); } else { Util.log("NFC not available. Adding friend via username."); showFriendPlayerDialog(); } } }); if (mCheckName) { if ((mPrivacyDialog.getNewName() != null) && !mPrivacyDialog.getNewName().equals(mAdapter.getPlayerName())) { Toast.makeText(getActivity(), R.string.name_taken, Toast.LENGTH_SHORT).show(); } mCheckName = false; } return v; }
From source file:net.primeranks.fs_viewer.fs_replay.EntryPointActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.entry_point); ListView listView = getListView(); listView.setOnItemClickListener(this); // Add a back to top button on the bottom - Create the item backToTop_footer = (Button) getLayoutInflater().inflate(R.layout.user_footer, null); backToTop_footer.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(android.R.drawable.ic_menu_upload), null, null, null); backToTop_footer.setVisibility(View.INVISIBLE); // While empty do not show it headerUser = getLayoutInflater().inflate(R.layout.user_header, null); listView.addFooterView(backToTop_footer, null, true); // Add it to the bottom listView.addHeaderView(headerUser, null, false); userList = new ArrayList<User>(); // Start with an empty one this.userAdapter = new UserAdapter(this, userList); listView.setAdapter(this.userAdapter); listView.setItemsCanFocus(false);//from w w w . j ava 2 s . c o m connectionReceiver = new ConnectionChangedBroadcastReceiver(); registerReceiver(connectionReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:com.redwoodsystems.android.apps.LightingListFragment.java
private void setupScenesList() { Log.d(TAG, "setupScenesList called"); ListView listView = (ListView) getActivity().findViewById(android.R.id.list); TextView dummy = new TextView(getActivity()); ImageView dummy2 = new ImageView(getActivity()); listView.addFooterView(dummy, null, true); listView.setFooterDividersEnabled(true); listView.addHeaderView(dummy2, null, true); listView.setHeaderDividersEnabled(true); int[] colors = { 0, 0xFFF47836, 0 }; // Pantone172 for the example listView.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); listView.setDividerHeight(1);//www .j a v a 2 s .c o m //TODO: set Empty Text inside View //setEmptyText("No Scenes found"); mSceneAdapter = new SceneAdapter(getActivity(), R.layout.scene_item_layout, R.id.sceneText); setListAdapter(mSceneAdapter); Uri dummyUri = null; Bundle params = new Bundle(); Bundle args = new Bundle(); args.putParcelable(ARGS_URI, dummyUri); args.putParcelable(ARGS_PARAMS, params); // Initialize the Loader. Log.d(TAG, "calling initLoader.."); getActivity().getSupportLoaderManager().initLoader(LOADER_SCENES, null, this); }
From source file:com.googlecode.eyesfree.utils.AccessibilityNodeInfoUtilsTest.java
public void testListWithNonSelectableHeader() throws Throwable { setContentView(R.layout.list_with_single_item); final Context context = getActivity(); final ListView list = (ListView) getViewForId(R.id.list); // Add a single list header. final LayoutInflater inflater = LayoutInflater.from(context); final View headerView = inflater.inflate(R.layout.list_header_row, list, false); // Add an adapter with two items. final ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1); adapter.add(context.getString(R.string.first_list_item)); adapter.add(context.getString(R.string.second_list_item)); runTestOnUiThread(new Runnable() { @Override/*from w ww . ja v a 2s .co m*/ public void run() { list.addHeaderView(headerView, mInsCtx.getString(R.string.list_header), false); list.setAdapter(adapter); } }); waitForAccessibilityIdleSync(); final View firstItem = list.getChildAt(1); final View secondItem = list.getChildAt(2); assertNotNull("Obtain first item", firstItem); assertNotNull("Obtain second item", secondItem); assertShouldFocusNode("Non-selectable header is focusable", R.id.header_item, true); assertShouldFocusNode("First item is focusable", firstItem, true); assertShouldFocusNode("Second item is focusable", secondItem, true); assertShouldFocusNode("List is not focusable", R.id.list, false); assertFocusFromHover("Non-selectable header receives focus", R.id.header_item, R.id.header_item); assertFocusFromHover("First item receives focus", firstItem, firstItem); assertFocusFromHover("Second item receives focus", secondItem, secondItem); assertFocusFromHover("List does not receive focus", R.id.list, -1); }
From source file:com.darshancomputing.BatteryIndicatorPro.LogViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); mInflater = inflater;//from ww w . j a v a2 s . com View logs_header = View.inflate(activity.context, R.layout.logs_header, null); header_text = (TextView) logs_header.findViewById(R.id.header_text); ListView lv = (ListView) view.findViewById(android.R.id.list); lv.addHeaderView(logs_header, null, false); setHeaderText(); setListAdapter(mAdapter); return view; }
From source file:com.stylovid.fastbattery.LogViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); mInflater = inflater;//from ww w.ja v a 2s .c o m View logs_header = View.inflate(getActivity(), R.layout.logs_header, null); header_text = (TextView) logs_header.findViewById(R.id.header_text); ListView lv = (ListView) view.findViewById(android.R.id.list); lv.addHeaderView(logs_header, null, false); lv.setFastScrollEnabled(true); if (noDB) return view; setHeaderText(); setListAdapter(mAdapter); return view; }
From source file:com.csipsimple.ui.filters.AccountFiltersListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ListView lv = getListView(); //getListView().setSelector(R.drawable.transparent); lv.setCacheColorHint(Color.TRANSPARENT); // View management View detailsFrame = getActivity().findViewById(R.id.details); dualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE; if (savedInstanceState != null) { // Restore last state for checked position. curCheckFilterId = savedInstanceState.getLong(CURRENT_CHOICE, SipProfile.INVALID_ID); //curCheckWizard = savedInstanceState.getString(CURRENT_WIZARD); }//from w w w . j a va 2s .c om setListShown(false); if (mAdapter == null) { if (mHeaderView != null) { lv.addHeaderView(mHeaderView, null, true); } mAdapter = new AccountFiltersListAdapter(getActivity(), null); //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container)); //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE); setListAdapter(mAdapter); registerForContextMenu(lv); lv.setVerticalFadingEdgeEnabled(true); } if (dualPane) { // In dual-pane mode, the list view highlights the selected item. Log.d("lp", "dual pane mode"); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); //lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT); lv.setVerticalScrollBarEnabled(false); lv.setFadingEdgeLength(50); updateCheckedItem(); // Make sure our UI is in the correct state. //showDetails(curCheckPosition, curCheckWizard); } else { //getListView().setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT); lv.setVerticalScrollBarEnabled(true); lv.setFadingEdgeLength(100); } }
From source file:com.silentcircle.contacts.list.ScDefaultContactBrowseListFragment.java
/** * This method creates a pseudo user profile contact. When the returned query doesn't have * a profile, this methods creates 2 views that are inserted as headers to the listview: * 1. A header view with the "ME" title and the contacts count. * 2. A button that prompts the user to create a local profile */// w ww . ja va2 s . com @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void addEmptyUserProfileHeader(LayoutInflater inflater) { ListView list = getListView(); // Put a header with the "ME" name and a view for the number of contacts // The view is embedded in a frame view since you cannot change the visibility of a // view in a ListView without having a parent view. mProfileHeaderContainer = new FrameLayout(inflater.getContext()); mProfileHeader = inflater.inflate(R.layout.user_profile_header, null, false); mCounterHeaderView = (TextView) mProfileHeader.findViewById(R.id.contacts_count); mProfileTitle = (TextView) mProfileHeader.findViewById(R.id.profile_title); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) mProfileTitle.setAllCaps(true); mProfileHeaderContainer.addView(mProfileHeader); list.addHeaderView(mProfileHeaderContainer, null, false); // Add a selectable view with a message inviting the user to create a local profile mMessageContainer = new FrameLayout(inflater.getContext()); mProfileMessage = (Button) inflater.inflate(R.layout.user_profile_button, null, false); mMessageContainer.addView(mProfileMessage); list.addHeaderView(mMessageContainer, null, true); mProfileMessage.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_INSERT, RawContacts.CONTENT_URI); intent.putExtra(ContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE, true); startActivity(intent); } }); }
From source file:com.gh4a.IssueActivity.java
private void fillData() { new LoadCommentsTask(this).execute(); Typeface boldCondensed = getApplicationContext().boldCondensed; ListView lvComments = (ListView) findViewById(R.id.list_view); // set details inside listview header LayoutInflater infalter = getLayoutInflater(); LinearLayout mHeader = (LinearLayout) infalter.inflate(R.layout.issue_header, lvComments, false); mHeader.setClickable(false);// w w w. j a v a 2 s . c o m lvComments.addHeaderView(mHeader, null, false); RelativeLayout rlComment = (RelativeLayout) findViewById(R.id.rl_comment); if (!isAuthorized()) { rlComment.setVisibility(View.GONE); } TextView tvCommentTitle = (TextView) mHeader.findViewById(R.id.comment_title); mCommentAdapter = new CommentAdapter(IssueActivity.this, new ArrayList<Comment>(), mIssue.getNumber(), mIssue.getState(), mRepoOwner, mRepoName); lvComments.setAdapter(mCommentAdapter); ImageView ivGravatar = (ImageView) mHeader.findViewById(R.id.iv_gravatar); aq.id(R.id.iv_gravatar).image(GravatarUtils.getGravatarUrl(mIssue.getUser().getGravatarId()), true, false, 0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN); ivGravatar.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { getApplicationContext().openUserInfoActivity(IssueActivity.this, mIssue.getUser().getLogin(), null); } }); TextView tvExtra = (TextView) mHeader.findViewById(R.id.tv_extra); TextView tvState = (TextView) mHeader.findViewById(R.id.tv_state); TextView tvTitle = (TextView) mHeader.findViewById(R.id.tv_title); TextView tvDescTitle = (TextView) mHeader.findViewById(R.id.desc_title); tvDescTitle.setTypeface(getApplicationContext().boldCondensed); tvDescTitle.setTextColor(Color.parseColor("#0099cc")); tvCommentTitle.setTypeface(getApplicationContext().boldCondensed); tvCommentTitle.setTextColor(Color.parseColor("#0099cc")); tvCommentTitle .setText(getResources().getString(R.string.issue_comments) + " (" + mIssue.getComments() + ")"); TextView tvDesc = (TextView) mHeader.findViewById(R.id.tv_desc); tvDesc.setMovementMethod(LinkMovementMethod.getInstance()); TextView tvMilestone = (TextView) mHeader.findViewById(R.id.tv_milestone); ImageView ivComment = (ImageView) findViewById(R.id.iv_comment); if (Gh4Application.THEME == R.style.DefaultTheme) { ivComment.setImageResource(R.drawable.social_send_now_dark); } ivComment.setBackgroundResource(R.drawable.abs__list_selector_holo_dark); ivComment.setPadding(5, 2, 5, 2); ivComment.setOnClickListener(this); tvExtra.setText(mIssue.getUser().getLogin() + "\n" + pt.format(mIssue.getCreatedAt())); tvState.setTextColor(Color.WHITE); if ("closed".equals(mIssue.getState())) { tvState.setBackgroundResource(R.drawable.default_red_box); tvState.setText("C\nL\nO\nS\nE\nD"); } else { tvState.setBackgroundResource(R.drawable.default_green_box); tvState.setText("O\nP\nE\nN"); } tvTitle.setText(mIssue.getTitle()); tvTitle.setTypeface(boldCondensed); boolean showInfoBox = false; if (mIssue.getAssignee() != null) { showInfoBox = true; TextView tvAssignee = (TextView) mHeader.findViewById(R.id.tv_assignee); tvAssignee.setText(mIssue.getAssignee().getLogin() + " is assigned"); tvAssignee.setVisibility(View.VISIBLE); tvAssignee.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { getApplicationContext().openUserInfoActivity(IssueActivity.this, mIssue.getAssignee().getLogin(), null); } }); ImageView ivAssignee = (ImageView) mHeader.findViewById(R.id.iv_assignee); aq.id(R.id.iv_assignee).image(GravatarUtils.getGravatarUrl(mIssue.getAssignee().getGravatarId()), true, false, 0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN); ivAssignee.setVisibility(View.VISIBLE); ivAssignee.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { getApplicationContext().openUserInfoActivity(IssueActivity.this, mIssue.getAssignee().getLogin(), null); } }); } if (mIssue.getMilestone() != null) { showInfoBox = true; tvMilestone.setText( getResources().getString(R.string.issue_milestone) + ": " + mIssue.getMilestone().getTitle()); } else { tvMilestone.setVisibility(View.GONE); } String body = mIssue.getBodyHtml(); if (!StringUtils.isBlank(body)) { HttpImageGetter imageGetter = new HttpImageGetter(this); body = HtmlUtils.format(body).toString(); imageGetter.bind(tvDesc, body, mIssue.getNumber()); } LinearLayout llLabels = (LinearLayout) findViewById(R.id.ll_labels); List<Label> labels = mIssue.getLabels(); if (labels != null && !labels.isEmpty()) { showInfoBox = true; for (Label label : labels) { TextView tvLabel = new TextView(this); tvLabel.setSingleLine(true); tvLabel.setText(label.getName()); tvLabel.setTextAppearance(this, R.style.default_text_small); tvLabel.setBackgroundColor(Color.parseColor("#" + label.getColor())); tvLabel.setPadding(5, 2, 5, 2); int r = Color.red(Color.parseColor("#" + label.getColor())); int g = Color.green(Color.parseColor("#" + label.getColor())); int b = Color.blue(Color.parseColor("#" + label.getColor())); if (r + g + b < 383) { tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_dark)); } else { tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_light)); } llLabels.addView(tvLabel); View v = new View(this); v.setLayoutParams(new LayoutParams(5, LayoutParams.WRAP_CONTENT)); llLabels.addView(v); } } else { llLabels.setVisibility(View.GONE); } TextView tvPull = (TextView) mHeader.findViewById(R.id.tv_pull); if (mIssue.getPullRequest() != null && mIssue.getPullRequest().getDiffUrl() != null) { showInfoBox = true; tvPull.setVisibility(View.VISIBLE); tvPull.setOnClickListener(this); } if (!showInfoBox) { RelativeLayout rl = (RelativeLayout) mHeader.findViewById(R.id.info_box); rl.setVisibility(View.GONE); } }