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

The following examples show how to use android.widget.ListView#setPadding() . 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
static ListView applyPadding(ListView listView, Display display) {
    listView.setClipToPadding(false);
    final int displayHeight = display.getHeight();
    int heightViewBasedTopPadding = displayHeight / 6;
    if (getTotalHeightOfListView(listView) < displayHeight - heightViewBasedTopPadding) {
        heightViewBasedTopPadding = (displayHeight / 2) - (getTotalHeightOfListView(listView) / 2);
    }
    listView.setPadding(0, heightViewBasedTopPadding, 0, 50);
    return listView;
}
 
Example 2
Source Project: EventApp   File: AppListFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    int padding = (int) (getResources().getDisplayMetrics().density * 8); // 8dip
    ListView listView = getListView();
    listView.setPadding(padding, 0, padding, 0);
    listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
    listView.setDivider(null);

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View header = inflater.inflate(R.layout.list_header_footer, listView, false);
    View footer = inflater.inflate(R.layout.list_footer, listView, false);

    TextView tv = (TextView) footer.findViewById(R.id.footer);
    String str = getResources().getString(R.string.footer);
    MovementMethod method = LinkMovementMethod.getInstance();
    tv.setMovementMethod(method);
    CharSequence html = Html.fromHtml(str);
    tv.setText(html);

    listView.addHeaderView(header, null, false);
    listView.addFooterView(footer, null, false);

    setTrack(7);
}
 
Example 3
Source Project: Dashchan   File: BaseListFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.activity_common, container, false);
	ListView listView = view.findViewById(android.R.id.list);
	emptyView = view.findViewById(R.id.error);
	emptyText = view.findViewById(R.id.error_text);
	emptyView.setVisibility(View.GONE);
	listView.setOnItemClickListener(this);
	registerForContextMenu(listView);
	ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
	try {
		layoutParams.getClass().getDeclaredField("removeBorders").set(layoutParams, true);
		if (!C.API_MARSHMALLOW) {
			float density = ResourceUtils.obtainDensity(inflater.getContext());
			int padding = (int) ((C.API_LOLLIPOP ? 8f : 16f) * density);
			listView.setPadding(padding, 0, padding, 0);
		}
		listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
	} catch (Exception e) {
		// Reflective operation, ignore exception
	}
	this.listView = listView;
	return view;
}
 
Example 4
Source Project: CrawlerForReader   File: ListDialog.java    License: Apache License 2.0 5 votes vote down vote up
public ListDialog.Builder setList(final String[] titles, final OnItemClickListener onItemClickListener) {
    if (titles == null || titles.length <= 0)
        return this;
    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this.context, android.R.layout.simple_list_item_1);
    for (String title : titles) {
        arrayAdapter.add(title + "");
    }

    ListView listView = new ListView(context);
    listView.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    float scale = context.getApplicationContext().getResources().getDisplayMetrics().density;
    int dpAsPixels = (int) (8 * scale + 0.5f);
    listView.setPadding(0, dpAsPixels, 0, dpAsPixels);
    listView.setDividerHeight(0);
    listView.setAdapter(arrayAdapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (onItemClickListener != null) {
                onItemClickListener.onItemClick(realBuilder, position, titles[position]);
            }
            realBuilder.dismiss();
        }
    });

    realBuilder.setContentView(listView);
    realBuilder.setCanceledOnTouchOutside(true);
    return this;
}
 
Example 5
Source Project: MDPreference   File: PreferenceFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ListView listView = (ListView) view.findViewById(android.R.id.list);
    listView.setPadding(PADDING_LEFT_RIGHT, 0, PADDING_LEFT_RIGHT, 0);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setFooterDividersEnabled(false);
}
 
Example 6
Source Project: intra42   File: UserQuestsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    ListView listView = view.findViewById(R.id.listView);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    int padding = Math.round(getResources().getDimension(R.dimen.card_spacing_half));
    listView.setPadding(0, padding, 0, padding);
}
 
Example 7
Source Project: SimplicityBrowser   File: PluginsFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    View rootView = getView();
    if (rootView != null) {
        ListView list = rootView.findViewById(android.R.id.list);
        list.setPadding(0, 0, 0, 0);
        list.setDivider(null);
        mListStyled = true;
    }

}
 
Example 8
/** Create the dialog where the user can choose the current layer.
    @param savedInstanceState the saved instance state (not used).
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    final Activity context = getActivity();
    final Dialog dialog = new Dialog(context);

    drawingPanel = (FidoEditor)context.findViewById(R.id.drawingPanel);
    layerButton= (Button)context.findViewById(R.id.layer);

    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.open_file);

    final Vector<LayerDesc> layers =
        drawingPanel.getDrawingModel().getLayers();

    // Here we create an adapter for the list. It is the custom class
    // defined in this very file.
    LayerAdapter customLayerAdapter = new LayerAdapter(
            context,
            R.layout.layer_spinner_item,
            layers);

    // We associate the adapter with the
    ListView list = (ListView) dialog.findViewById(R.id.fileList);
    list.setAdapter(customLayerAdapter);
    list.setPadding(10, 10, 10, 10);
    diag=dialog;
    return dialog;
}
 
Example 9
@Override
protected void onResume() {
    super.onResume();
    // Just a hack to remove section dividers
    if (!mListStyled) {
        View rootView = findViewById(android.R.id.content);
        if (rootView != null) {
            ListView list = (ListView) rootView.findViewById(android.R.id.list);
            list.setPadding(0, 0, 0, 0);
            list.setDivider(null);
            //any other styling call
            mListStyled = true;
        }
    }
}
 
Example 10
@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);
}
 
Example 11
Source Project: android-discourse   File: TopicFragment.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 12
@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);
}
 
Example 13
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);
    if (v != null) {
        if (mPreferenceScreen != null && getPreferenceScreen() == null) {
            super.setPreferenceScreen(mPreferenceScreen);
        }
        ListView lv = (ListView) v.findViewById(android.R.id.list);
        lv.setPadding(0, 0, 0, 0);

        //Override PreferenceScreen click and preferences style
        for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
            Preference preference = getPreferenceScreen().getPreference(i);

            if (preference instanceof PreferenceCategory) {
                for (int j = 0; j < ((PreferenceCategory) preference).getPreferenceCount();
                     j++) {
                    preferenceToMaterialPreference(((PreferenceCategory) preference)
                            .getPreference(j));
                }
            }

            preferenceToMaterialPreference(preference);
        }
    }
    return v;
}
 
Example 14
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quick_launch);
    setTitle(getResources().getString(R.string.select_profile));

    // Get array of profiles
    final String[][] profileList = U.listProfiles(this, "show_list", R.string.show_list);

    // If there are no saved profiles, then show a toast message and exit
    if(profileList == null) {
        U.showToast(this, R.string.no_profiles_found);
        finish();
    } else {
        // Create ArrayList and populate with list of profiles
        ArrayList<String> arrayList = new ArrayList<>(profileList[1].length);
        arrayList.addAll(Arrays.asList(profileList[1]));

        // Create the custom adapter to bind the array to the ListView
        final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, arrayList);

        // Display the ListView
        final ListView listView = findViewById(R.id.listView2);
        listView.setPadding(getResources().getDimensionPixelSize(R.dimen.list_view_padding), 0, 0, 0);
        listView.setAdapter(adapter);
        listView.setClickable(true);
        listView.setOnItemClickListener((arg0, arg1, position, arg3) -> {
            SharedPreferences prefMain = U.getPrefMain(this);
            SharedPreferences.Editor editor = prefMain.edit();
            editor.putString("hdmi_load_profile", profileList[0][position]);
            editor.apply();

            finish();
        });
    }
}
 
Example 15
Source Project: UltimateAndroid   File: SuperListview.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void initAbsListView(View v) {

    View listView = v.findViewById(android.R.id.list);

    if (listView instanceof ListView)
        mList = (ListView) listView;
    else
        throw new IllegalArgumentException("SuperListView works with a List!");


    if (mList != null) {


        mList.setClipToPadding(mClipToPadding);

        //getList().setDivider(mDivider);
        getList().setDividerHeight((int) mDividerHeight);

        mList.setOnScrollListener(this);
        if (mSelector != 0)
            mList.setSelector(mSelector);

        if (mPadding != -1.0f) {
            mList.setPadding(mPadding, mPadding, mPadding, mPadding);
        } else {
            mList.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
        }

        if (mScrollbarStyle != -1)
            mList.setScrollBarStyle(mScrollbarStyle);
    }
}
 
Example 16
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
	 mAdapter.swapCursor(data);
	 ListView lv = getListView();
	 lv.setFastScrollEnabled(true);
	 lv.setFastScrollAlwaysVisible(true);
	 if (isTwoPane()){
		 lv.setVerticalScrollbarPosition(ListView.SCROLLBAR_POSITION_LEFT);
		 lv.setPadding(15, 0, 0, 0);
	 }
}
 
Example 17
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    PackageManager packageManager = getActivity().getPackageManager();
    List<PackageInfo> packageInfoList = packageManager.getInstalledPackages(PackageManager.GET_ACTIVITIES);

    CardListAdapter adapter = new CardListAdapter(getActivity());

    if (packageInfoList != null) {
        for (PackageInfo info : packageInfoList) {
            adapter.add(info);
        }
    }

    int padding = (int) (getResources().getDisplayMetrics().density * 8); // 8dip
    ListView listView = getListView();
    listView.setPadding(padding, 0, padding, 0);
    listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
    listView.setDivider(null);

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View header = inflater.inflate(R.layout.list_header_footer, listView, false);
    View footer = inflater.inflate(R.layout.list_header_footer, listView, false);
    listView.addHeaderView(header, null, false);
    listView.addFooterView(footer, null, false);

    setListAdapter(adapter);
}
 
Example 18
@SuppressWarnings("unchecked")
@Override
public View createView(Context context) {
    actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
    // actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackText(context.getString(R.string.Cancel));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == 1) {
                if (delegate != null) {
                    finishFragment(false);
                    delegate.startPhotoSelectActivity();
                }
            } else if (id == item_photos) {
                refreshShowPic();//刷新照片目录
            } else if (id == item_video) {
                refreshShowVedio();//刷新录像目录
            }
        }
    });


    fragmentView = new FrameLayout(context);

    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(DarkTheme ? 0xff000000 : 0xffffffff);
    //==============videos pick====================
    int res = !singlePhoto && filterMimeTypes.length > 0 ? R.string.PickerVideo : R.string.Album;
    actionBar.setTitle(context.getString(res));
    selectedMode = filterMimeTypes.length > 0 ? 1 : selectedMode;
    listView = new ListView(context);
    listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4),
            AndroidUtilities.dp(4));
    listView.setClipToPadding(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(0));
    listView.setDividerHeight(0);
    listView.setDivider(null);
    listView.setDrawingCacheEnabled(false);
    listView.setScrollingCacheEnabled(false);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView
            .getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    // layoutParams.bottomMargin = AndroidUtilities.dp(48);
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);

    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setText(R.string.NoPhotos);
    frameLayout.addView(emptyView);
    layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    emptyView.setLayoutParams(layoutParams);
    emptyView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    progressView = new FrameLayout(context);
    progressView.setVisibility(View.GONE);
    frameLayout.addView(progressView);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    progressView.setLayoutParams(layoutParams);

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);


    if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
        progressView.setVisibility(View.VISIBLE);
        listView.setEmptyView(null);
    } else {
        progressView.setVisibility(View.GONE);
        listView.setEmptyView(emptyView);
    }
    return fragmentView;
}
 
Example 19
/**
 * 构建内容视图
 * @return 内容视图
 */
private View createContentView(){
	rootContainer = new LinearLayout(context);
	rootContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	rootContainer.setBackgroundColor(backgroundColor);
	rootContainer.setOrientation(LinearLayout.VERTICAL);
	topLineView = new View(context);
	topLineView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, (int)(topLineHeight * DP)));
	topLineView.setBackgroundColor(topLineColor);
	dataContainer = new LinearLayout(context);
	dataContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	dataContainer.setOrientation(LinearLayout.HORIZONTAL);
	dataContainer.setGravity(Gravity.CENTER);
	int paddingPixel = (int)(padding * DP);
	switch (mode) {
	case 3:
		thirdListView = new ListView(context);
		thirdListView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
		thirdListView.setPadding(paddingPixel, paddingPixel, paddingPixel, paddingPixel);
		thirdListView.setSelector(new ColorDrawable(Color.TRANSPARENT));
		thirdListView.setDivider(new ColorDrawable(Color.TRANSPARENT));
		thirdListView.setOnItemClickListener(itemClickListener);
		thirdListView.setAdapter(dataAdapters.get(2));
		thirdListView.setTag(dataAdapters.get(2));
	case 2:
		secondListView = new ListView(context);
		secondListView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
		secondListView.setPadding(paddingPixel, paddingPixel, paddingPixel, paddingPixel);
		secondListView.setSelector(new ColorDrawable(Color.TRANSPARENT));
		secondListView.setDivider(new ColorDrawable(Color.TRANSPARENT));
		secondListView.setOnItemClickListener(itemClickListener);
		secondListView.setAdapter(dataAdapters.get(1));
		secondListView.setTag(dataAdapters.get(1));
	case 1:
		fristListView = new ListView(context);
		fristListView.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
		fristListView.setPadding(paddingPixel, paddingPixel, paddingPixel, paddingPixel);
		fristListView.setSelector(new ColorDrawable(Color.TRANSPARENT));
		fristListView.setDivider(new ColorDrawable(Color.TRANSPARENT));
		fristListView.setOnItemClickListener(itemClickListener);
		fristListView.setAdapter(dataAdapters.get(0));
		fristListView.setTag(dataAdapters.get(0));
		break;
	default:
		break;
	}
	
	dataContainer.addView(fristListView);
	if (secondListView != null) {
		leftLineView = new View(context);
		leftLineView.setLayoutParams(new LayoutParams((int)(leftLineWidth * DP), LayoutParams.MATCH_PARENT));
		leftLineView.setBackgroundColor(leftLineColor);
		dataContainer.addView(leftLineView);
		dataContainer.addView(secondListView);
	}
	if (thirdListView != null) {
		rightLineView = new View(context);
		rightLineView.setLayoutParams(new LayoutParams((int)(rightLineWidth * DP), LayoutParams.MATCH_PARENT));
		rightLineView.setBackgroundColor(rightLineColor);
		dataContainer.addView(rightLineView);
		dataContainer.addView(thirdListView);
	}
	rootContainer.addView(topLineView);
	rootContainer.addView(dataContainer);
	
	return rootContainer;
}
 
Example 20
Source Project: YiBo   File: AccountsActivity.java    License: Apache License 2.0 4 votes vote down vote up
private void initComponents() {
	LinearLayout llRoot = (LinearLayout)findViewById(R.id.llRoot);
   	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
   	ThemeUtil.setRootBackground(llRoot);
   	ThemeUtil.setSecondaryHeader(llHeaderBase);

   	//通行证头部
   	LinearLayout llPassport = (LinearLayout)findViewById(R.id.llPassport);
   	ImageView ivPassportPicture = (ImageView)findViewById(R.id.ivPassportPicture);
   	TextView tvPassportEmail = (TextView)findViewById(R.id.tvPassportEmail);
   	TextView tvUsageDescription = (TextView)findViewById(R.id.tvUsageDescription);
   	Button btnPassport = (Button)findViewById(R.id.btnPassport);
   	ThemeUtil.setHeaderProfile(llPassport);
   	ivPassportPicture.setImageDrawable(theme.getDrawable("icon_header_default"));
   	int content = theme.getColor("content");
   	tvPassportEmail.setTextColor(content);
   	tvUsageDescription.setTextColor(theme.getColor("quote"));
   	ThemeUtil.setBtnActionPositive(btnPassport);

   	//帐号列表
   	ListView lvAccounts = (ListView)findViewById(R.id.lvAccounts);
   	LinearLayout llAddAccountFrame = (LinearLayout)findViewById(R.id.llAddAccountFrame);
   	LinearLayout llAddAccount = (LinearLayout)findViewById(R.id.llAddAccount);
   	ImageView ivAddAccount = (ImageView)findViewById(R.id.ivAddAccount);
   	TextView tvAddAccount = (TextView)findViewById(R.id.tvAddAccount);
   	ImageView ivAddAccountMore = (ImageView)findViewById(R.id.ivAddAccountMore);
   	lvAccounts.setBackgroundDrawable(theme.getDrawable("bg_frame_normal"));
   	lvAccounts.setPadding(0, 0, 0, 0);
   	ThemeUtil.setListViewStyle(lvAccounts);
   	llAddAccountFrame.setBackgroundDrawable(theme.getDrawable("bg_frame_normal"));
   	int padding1 = theme.dip2px(1);
   	llAddAccountFrame.setPadding(padding1, padding1, padding1, padding1);
   	llAddAccount.setBackgroundDrawable(theme.getDrawable("selector_frame_item_all_corner"));
   	int padding8 = theme.dip2px(8);
   	llAddAccount.setPadding(padding8, padding8, padding8, padding8);
   	ivAddAccount.setImageDrawable(theme.getDrawable("icon_account_add_normal"));
   	tvAddAccount.setTextColor(content);
   	ivAddAccountMore.setImageDrawable(theme.getDrawable("icon_more_detail"));

   	//工具栏
   	LinearLayout llFooterAction = (LinearLayout)findViewById(R.id.llFooterAction);
   	ImageView ivAccountSync = (ImageView)findViewById(R.id.ivAccountSync);
   	TextView tvAccountSync = (TextView)findViewById(R.id.tvAccountSync);
   	TextView tvLastSyncTime = (TextView)findViewById(R.id.tvLastSyncTime);
   	Button btnAccountSync = (Button)findViewById(R.id.btnAccountSync);
   	llFooterAction.setBackgroundDrawable(theme.getDrawable("bg_footer_action"));
   	int padding12 = theme.dip2px(12);
   	llFooterAction.setPadding(padding12, padding8, padding12, padding8);
   	ivAccountSync.setImageDrawable(theme.getDrawable("icon_account_sync_normal"));
   	tvAccountSync.setTextColor(content);
   	tvLastSyncTime.setTextColor(content);
   	ThemeUtil.setBtnActionNegative(btnAccountSync);

   	TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle);
	tvTitle.setText(getString(R.string.title_accounts));
}