下面列出了android.widget.ListView#setDrawSelectorOnTop ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Context context = getActivity();
FrameLayout root = new FrameLayout(context);
LinearLayout pframe = new LinearLayout(context);
pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
pframe.setOrientation(1);
pframe.setVisibility(8);
pframe.setGravity(17);
pframe.addView(new ProgressBar(context, null, 16842874), new LayoutParams(-2, -2));
root.addView(pframe, new LayoutParams(-1, -1));
FrameLayout lframe = new FrameLayout(context);
lframe.setId(INTERNAL_LIST_CONTAINER_ID);
TextView tv = new TextView(getActivity());
tv.setId(INTERNAL_EMPTY_ID);
tv.setGravity(17);
lframe.addView(tv, new LayoutParams(-1, -1));
ListView lv = new ListView(getActivity());
lv.setId(16908298);
lv.setDrawSelectorOnTop(false);
lframe.addView(lv, new LayoutParams(-1, -1));
root.addView(lframe, new LayoutParams(-1, -1));
root.setLayoutParams(new LayoutParams(-1, -1));
return root;
}
public View onCreateView(LayoutInflater layoutinflater, ViewGroup viewgroup, Bundle bundle)
{
FragmentActivity fragmentactivity = getActivity();
FrameLayout framelayout = new FrameLayout(fragmentactivity);
LinearLayout linearlayout = new LinearLayout(fragmentactivity);
linearlayout.setId(0xff0002);
linearlayout.setOrientation(1);
linearlayout.setVisibility(8);
linearlayout.setGravity(17);
linearlayout.addView(new ProgressBar(fragmentactivity, null, 0x101007a), new android.widget.FrameLayout.LayoutParams(-2, -2));
framelayout.addView(linearlayout, new android.widget.FrameLayout.LayoutParams(-1, -1));
FrameLayout framelayout1 = new FrameLayout(fragmentactivity);
framelayout1.setId(0xff0003);
TextView textview = new TextView(getActivity());
textview.setId(0xff0001);
textview.setGravity(17);
framelayout1.addView(textview, new android.widget.FrameLayout.LayoutParams(-1, -1));
ListView listview = new ListView(getActivity());
listview.setId(0x102000a);
listview.setDrawSelectorOnTop(false);
framelayout1.addView(listview, new android.widget.FrameLayout.LayoutParams(-1, -1));
framelayout.addView(framelayout1, new android.widget.FrameLayout.LayoutParams(-1, -1));
framelayout.setLayoutParams(new android.widget.FrameLayout.LayoutParams(-1, -1));
return framelayout;
}
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
FrameLayout lframe = new FrameLayout(getActivity());
ListView lv = new ListView(getActivity());
lv.setId(android.R.id.list);
lv.setDrawSelectorOnTop(false);
lframe.addView(lv,
new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
lframe.setBackgroundColor(getResources().getColor(android.R.color.background_light));
ArrayAdapter<Parcelable> adapter = new SoftwareArrayAdapter(getActivity(), R.layout.item_open_source_licenses);
if (getArguments() != null && getArguments().containsKey(EXTRA_OSS)) {
adapter.addAll(getArguments().getParcelableArrayList(EXTRA_OSS));
}
ListView listView = lframe.findViewById(android.R.id.list);
listView.setAdapter(adapter);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.activity_settings_open_source_licenses);
builder.setView(lframe);
builder.setPositiveButton(R.string.activity_settings_close, (dialog, which) -> {
dialog.dismiss();
});
return builder.create();
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final ListView listView = getListView();
// TODO fix this
// if (!UIUtils.isTablet(getActivity())) {
// view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color));
// }
// if (getArguments() != null
// && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {
// int verticalMargin = getResources().getDimensionPixelSize(
// R.dimen.plus_stream_padding_vertical);
// if (verticalMargin > 0) {
// listView.setClipToPadding(false);
// listView.setPadding(0, verticalMargin, 0, verticalMargin);
// }
// }
listView.setOnScrollListener(this);
listView.setDrawSelectorOnTop(true);
// listView.setDivider(getResources().getDrawable(android.R.color.darker_gray));
// listView.setDividerHeight(getResources()
// .getDimensionPixelSize(R.dimen.divider_height));
TypedValue v = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.clickableItemBackground, v, true);
listView.setSelector(v.resourceId);
setListAdapter(mAdapter);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final ListView listView = getListView();
if (!Utils.isTablet(getActivity())) {
// TODO ...
// view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color));
}
if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {
int verticalMargin = getResources().getDimensionPixelSize(R.dimen.categories_list_padding_vertical);
if (verticalMargin > 0) {
listView.setClipToPadding(false);
listView.setPadding(0, verticalMargin, 0, verticalMargin);
}
}
listView.setDrawSelectorOnTop(true);
// listView.setDivider(getResources().getDrawable(android.R.color.transparent));
// listView.setDividerHeight(getResources()
// .getDimensionPixelSize(R.dimen.page_margin_width));
TypedValue v = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.clickableItemBackground, v, true);
listView.setSelector(v.resourceId);
setListAdapter(mAdapter);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final ListView listView = getListView();
View header = LayoutInflater.from(getActivity()).inflate(R.layout.topic_header, listView, false);
mNotificationDesView = (TextView) header.findViewById(R.id.notification_des);
mCategoryView = (TextView) header.findViewById(R.id.category);
mNotificationSpinner = (Spinner) header.findViewById(R.id.notification_spinner);
mStatusView = (TextView) header.findViewById(R.id.topic_status_view);
mAdView = (AdView) view.findViewById(R.id.adView);
mCloseAd = view.findViewById(R.id.close_ad);
mCloseAd.setOnClickListener(this);
mAdView.setAdListener(this);
setupNotificationSpinner();
listView.addHeaderView(header);
if (!Utils.isTablet(getActivity())) {
// TODO ...
// view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color));
}
if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {
int verticalMargin = getResources().getDimensionPixelSize(R.dimen.topics_list_padding_vertical);
if (verticalMargin > 0) {
listView.setClipToPadding(false);
listView.setPadding(0, verticalMargin, 0, verticalMargin);
}
}
listView.setOnScrollListener(this);
listView.setDrawSelectorOnTop(true);
// listView.setDivider(getResources().getDrawable(android.R.color.transparent));
// listView.setDividerHeight(getResources()
// .getDimensionPixelSize(R.dimen.page_margin_width));
TypedValue v = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.clickableItemBackground, v, true);
listView.setSelector(v.resourceId);
setListAdapter(mAdapter);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final ListView listView = getListView();
if (!Utils.isTablet(getActivity())) {
// TODO ...
// view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color));
}
if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {
int verticalMargin = getResources().getDimensionPixelSize(R.dimen.topics_list_padding_vertical);
if (verticalMargin > 0) {
listView.setClipToPadding(false);
listView.setPadding(0, verticalMargin, 0, verticalMargin);
}
}
listView.setOnScrollListener(this);
listView.setDrawSelectorOnTop(true);
// listView.setDivider(getResources().getDrawable(android.R.color.transparent));
// listView.setDividerHeight(getResources()
// .getDimensionPixelSize(R.dimen.page_margin_width));
TypedValue v = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.clickableItemBackground, v, true);
listView.setSelector(v.resourceId);
setListAdapter(mAdapter);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = super.onCreateView(inflater, container, savedInstanceState);
ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);
listView.setDrawSelectorOnTop(true);
return view;
}
/**
* 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.
*
* <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.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final Context context = getActivity();
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.progressBarStyleLarge);
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);
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;
}
/**
* 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.
*
* <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.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final Context context = getActivity();
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.progressBarStyleLarge);
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);
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;
}
/**
* 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.
*
* <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.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final Context context = getActivity();
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.progressBarStyleLarge);
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);
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;
}
/**
* 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.
*
* <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.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final Context context = getActivity();
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.progressBarStyleLarge);
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);
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;
}
/**
* 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.
*
* <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.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final Context context = getActivity();
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.progressBarStyleLarge);
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);
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;
}