Java Code Examples for android.widget.ListView#setFadingEdgeLength()

The following examples show how to use android.widget.ListView#setFadingEdgeLength() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Android-Example   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
  
 metrics = new DisplayMetrics();
 getWindowManager().getDefaultDisplay().getMetrics(metrics);

 listview = new ListView(this);
 listview.setFadingEdgeLength(0);
 ArrayList<String> strings = new ArrayList<String>();

 for (int i = 0; i < 300; i++) {
  strings.add("Item:#" + (i + 1));
 }

 MainAdapter mAdapter = new MainAdapter(this, strings, metrics);
 listview.setAdapter(mAdapter);
 setContentView(listview);
}
 
Example 2
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView lv = new ListView(mContext);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setFadingEdgeLength(0);
    lv.setAdapter(new SimpleHomeAdapter(mContext, mItems));

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(mContext, mClasses[position]);
            startActivity(intent);
        }
    });

    setContentView(lv);
}
 
Example 3
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView lv = new ListView(mContext);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setFadingEdgeLength(0);
    lv.setAdapter(new SimpleHomeAdapter(mContext, mItems));

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(mContext, mClasses[position]);
            startActivity(intent);
        }
    });

    setContentView(lv);
}
 
Example 4
Source Project: FlycoTabLayout   File: SimpleHomeActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView lv = new ListView(mContext);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setFadingEdgeLength(0);
    lv.setAdapter(new SimpleHomeAdapter(mContext, mItems));

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(mContext, mClasses[position]);
            startActivity(intent);
        }
    });

    setContentView(lv);
}
 
Example 5
Source Project: FlycoDialog_Master   File: PopupHomeActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDisplayMetrics = getResources().getDisplayMetrics();

    ListView lv = new ListView(mContext);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setBackgroundColor(Color.WHITE);
    lv.setFadingEdgeLength(0);
    lv.setAdapter(new SimpleHomeAdapter());

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(mContext, mClazzs[position]);
            startActivity(intent);
        }
    });

    setContentView(lv);
}
 
Example 6
Source Project: FlycoDialog_Master   File: SimpleHomeActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDisplayMetrics = getResources().getDisplayMetrics();

    ListView lv = new ListView(mContext);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setBackgroundColor(Color.WHITE);
    lv.setFadingEdgeLength(0);
    lv.setAdapter(new SimpleHomeAdapter());

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(mContext, mClazzs[position]);
            startActivity(intent);
        }
    });

    setContentView(lv);
}
 
Example 7
Source Project: FlycoPageIndicator   File: SimpleHomeActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView lv = new ListView(context);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setFadingEdgeLength(0);
    lv.setAdapter(new SimpleHomeAdapter(context, items));

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(context, classes[position]);
            startActivity(intent);
        }
    });

    setContentView(lv);
}
 
Example 8
Source Project: SuperDialog   File: SuperDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 列表显示,显示列表屏蔽按钮
 */
private void initListView(ViewGroup viewRoot) {
    listView = new ListView(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.setMargins(dp2px(15), dp2px(5), dp2px(15), dp2px(5));
    listView.setLayoutParams(layoutParams);
    listView.setCacheColorHint(Color.TRANSPARENT);
    listView.setFadingEdgeLength(0);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(Color.TRANSPARENT));
    listView.setDivider(new ColorDrawable(Color.LTGRAY));
    listView.setDividerHeight(dp2px(0.8f));
    if (dialogAdapter == null) {
        dialogAdapter = new ListDialogAdapter();
    }
    listView.setAdapter(dialogAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            dismiss();
            if (listener != null) {
                listener.click(false, position);
            }
        }
    });

    listView.setLayoutAnimation(getLayoutAnimation());
    viewRoot.addView(listView);
}
 
Example 9
Source Project: SprintNBA   File: NormalListDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    mTvTitle.setSingleLine(true);
    mTvTitle.setPadding(dp2px(18), dp2px(10), 0, dp2px(10));

    ll_container.addView(mTvTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    return ll_container;
}
 
Example 10
Source Project: FlycoDialog_Master   File: NormalListDialog.java    License: MIT License 5 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    mTvTitle.setSingleLine(true);
    mTvTitle.setPadding(dp2px(18), dp2px(10), 0, dp2px(10));

    ll_container.addView(mTvTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    return ll_container;
}
 
Example 11
private void willShowPopupWindow() {
    int userCount = mListAdapter.getCount();
    if (userCount > mRememberCount) {
        userCount = mRememberCount;
    }
    int itemHeight = getResources().getDimensionPixelSize(R.dimen.remember_item_height);
    mPopupWindowHeight = itemHeight * userCount + (userCount - 1);
    if (pop == null) {
        mCacheListView = new ListView(getContext());
        mCacheListView.setCacheColorHint(0);
        mCacheListView.setScrollingCacheEnabled(false);
        mCacheListView.setFadingEdgeLength(0);
        mCacheListView.setDivider(new ColorDrawable(Color.GRAY));
        mCacheListView.setDividerHeight(1);

        LayoutParams params = new LayoutParams(getWidth(), mPopupWindowHeight);
        mCacheListView.setLayoutParams(params);

        mCacheListWrapperLinearLayout = new LinearLayout(getContext());
        mCacheListWrapperLinearLayout.setLayoutParams(params);
        mCacheListWrapperLinearLayout.addView(mCacheListView);
        pop = new SafePopupWindow(mCacheListWrapperLinearLayout, getWidth(), LayoutParams.WRAP_CONTENT);
        mCacheListView.setAdapter(mListAdapter);
    }
    pop.setAnimationStyle(R.style.RememberEditTextPopupWindowAnim);
    pop.showAsDropDown(this);
    mListAdapter.notifyDataSetChanged();
    mIconStatus = ICON_SHOW_DROP_UP;
}
 
Example 12
@Override
protected ListView createRefreshableView(Context context, AttributeSet attrs) {
    ListView lv = createListView(context, attrs);
    lv.setScrollingCacheEnabled(false);
    lv.setFadingEdgeLength(0);
    lv.setDivider(new ColorDrawable(Color.LTGRAY));
    lv.setCacheColorHint(Color.TRANSPARENT);
    // Set it to this so it can be used in ListActivity/ListFragment
    lv.setId(android.R.id.list);
    return lv;
}
 
Example 13
Source Project: AutoTest   File: ActionSheetDialog.java    License: MIT License 4 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);
    ll_container.setBackgroundColor(Color.TRANSPARENT);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setGravity(Gravity.CENTER);
    mTvTitle.setPadding(dp2px(10), dp2px(5), dp2px(10), dp2px(5));

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.topMargin = dp2px(20);

    ll_container.addView(mTvTitle, params);

    /** title underline */
    mVLineTitle = new View(mContext);
    ll_container.addView(mVLineTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    /** mCancel btn */
    mTvCancel = new TextView(mContext);
    mTvCancel.setGravity(Gravity.CENTER);
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.topMargin = dp2px(7);
    lp.bottomMargin = dp2px(7);
    mTvCancel.setLayoutParams(lp);

    ll_container.addView(mTvCancel);

    return ll_container;
}
 
Example 14
@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.
        curCheckPosition = savedInstanceState.getLong(CURRENT_CHOICE, SipProfile.INVALID_ID);
        //curCheckWizard = savedInstanceState.getString(CURRENT_WIZARD);
    }
    setListShown(false);
    if(mAdapter == null) {
        if(mHeaderView != null) {
            lv.addHeaderView(mHeaderView , null, true);
        }
        mAdapter = new AccountsEditListAdapter(getActivity(), null);
        mAdapter.setOnCheckedRowListener(this);
        //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container));
        //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE);
        setListAdapter(mAdapter);
        registerForContextMenu(lv);

        // Prepare the loader.  Either re-connect with an existing one,
        // or start a new one.
        getLoaderManager().initLoader(0, null, this);
        
        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);
    }
}
 
Example 15
@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);
    }
    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);
    }
}
 
Example 16
Source Project: RecordVideo   File: ActionSheetDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);
    ll_container.setBackgroundColor(Color.TRANSPARENT);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setGravity(Gravity.CENTER);
    mTvTitle.setPadding(dp2px(10), dp2px(5), dp2px(10), dp2px(5));

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.topMargin = dp2px(20);

    ll_container.addView(mTvTitle, params);

    /** title underline */
    mVLineTitle = new View(mContext);
    ll_container.addView(mVLineTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    TextView cancelDivider = new TextView(mContext);
    cancelDivider.setGravity(Gravity.CENTER);
    cancelDivider.setBackgroundColor(Color.parseColor("#ffefefef"));
    LayoutParams clp = new LayoutParams(LayoutParams.MATCH_PARENT, 20);
    cancelDivider.setLayoutParams(clp);
    ll_container.addView(cancelDivider);
    /** mCancel btn */
    mTvCancel = new TextView(mContext);
    mTvCancel.setGravity(Gravity.CENTER);
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.topMargin = dp2px(0);
    lp.bottomMargin = dp2px(0);
    mTvCancel.setLayoutParams(lp);

    ll_container.addView(mTvCancel);

    return ll_container;
}
 
Example 17
Source Project: SprintNBA   File: ActionSheetDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);
    ll_container.setBackgroundColor(Color.TRANSPARENT);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setGravity(Gravity.CENTER);
    mTvTitle.setPadding(dp2px(10), dp2px(5), dp2px(10), dp2px(5));

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.topMargin = dp2px(20);

    ll_container.addView(mTvTitle, params);

    /** title underline */
    mVLineTitle = new View(mContext);
    ll_container.addView(mVLineTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    /** mCancel btn */
    mTvCancel = new TextView(mContext);
    mTvCancel.setGravity(Gravity.CENTER);
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.topMargin = dp2px(7);
    lp.bottomMargin = dp2px(7);
    mTvCancel.setLayoutParams(lp);

    ll_container.addView(mTvCancel);

    return ll_container;
}
 
Example 18
Source Project: FlycoDialog_Master   File: ActionSheetDialog.java    License: MIT License 4 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);
    ll_container.setBackgroundColor(Color.TRANSPARENT);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setGravity(Gravity.CENTER);
    mTvTitle.setPadding(dp2px(10), dp2px(5), dp2px(10), dp2px(5));

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.topMargin = dp2px(20);

    ll_container.addView(mTvTitle, params);

    /** title underline */
    mVLineTitle = new View(mContext);
    ll_container.addView(mVLineTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    /** mCancel btn */
    mTvCancel = new TextView(mContext);
    mTvCancel.setGravity(Gravity.CENTER);
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.topMargin = dp2px(7);
    lp.bottomMargin = dp2px(7);
    mTvCancel.setLayoutParams(lp);

    ll_container.addView(mTvCancel);

    return ll_container;
}