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

The following are Jave code examples for showing how to use setPadding() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CCDownload   File: PopMenu.java   View Source Code Vote up 6 votes
public PopMenu(Context context, int resid, int checkedPosition, int height) {
		this.context = context;
		this.checkedPosition = checkedPosition;

		itemList = new ArrayList<String>();
		RelativeLayout view = new RelativeLayout(context);
//		view.setBackgroundResource(resid);

		listView = new ListView(context);
		listView.setPadding(0, ParamsUtil.dpToPx(context, 3), 0, ParamsUtil.dpToPx(context, 3));
		view.addView(listView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		listView.setAdapter(new PopAdapter());
		listView.setOnItemClickListener(this);

		popupWindow = new PopupWindow(view, context.getResources().getDimensionPixelSize(R.dimen.popmenu_width), height);
		popupWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(178, 0, 0, 0)));
	}
 
Example 2
Project: CCDownload   File: DownloadedFragment.java   View Source Code Vote up 6 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	activity = getActivity();
	context = activity.getApplicationContext();
	RelativeLayout downloadLayout = new RelativeLayout(activity.getApplicationContext());
	downloadLayout.setBackgroundColor(Color.WHITE);
	receiver = new DownloadedReceiver();
	activity.registerReceiver(receiver, new IntentFilter(ConfigUtil.ACTION_DOWNLOADED));
	
	downloadedListView = new ListView(context);
	downloadedListView.setPadding(10, 10, 10, 10);
	downloadedListView.setDivider(getResources().getDrawable(R.drawable.line));
	LayoutParams downloadedLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	downloadLayout.addView(downloadedListView, downloadedLayoutParams);
	
	initData();

	downloadedListView.setOnItemClickListener(onItemClickListener);
	downloadedListView.setOnCreateContextMenuListener(onCreateContextMenuListener);

	return downloadLayout;
}
 
Example 3
Project: CCDownload   File: PlayChangeVideoPopupWindow.java   View Source Code Vote up 5 votes
public PlayChangeVideoPopupWindow(Context context, int height) {
	this.context = context;
	
	RelativeLayout view = new RelativeLayout(context);

	listView = new ListView(context);
	listView.setPadding(0, ParamsUtil.dpToPx(context, 3), 0, ParamsUtil.dpToPx(context, 3));
	view.addView(listView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	adapter = new VideosAdapter();
	listView.setAdapter(adapter);
	
	popupWindow = new PopupWindow(view, height * 2 / 3 , height);
	popupWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(178, 0, 0, 0)));
}
 
Example 4
Project: CCDownload   File: AccountInfoActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
	getActionBar().setDisplayHomeAsUpEnabled(true);
	RelativeLayout accountLayout = new RelativeLayout(this);
	accountLayout.setBackgroundColor(Color.WHITE);
	LayoutParams accountLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	accountLayout.setLayoutParams(accountLayoutParams);
	
	ListView accountListView = new ListView(this);
	accountListView.setPadding(10, 10, 10, 10);
	accountListView.setDivider(getResources().getDrawable(R.drawable.line));
	LayoutParams accountListViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	accountLayout.addView(accountListView, accountListViewParams);
	
	List<Pair<String, String>> pairs = new ArrayList<Pair<String,String>>();
	Pair<String, String> userIdPair = new Pair<String, String>("User ID",ConfigUtil.USERID);
	pairs.add(userIdPair);
	Pair<String, String> apiKeyPair = new Pair<String, String>("API Key", ConfigUtil.API_KEY);
	pairs.add(apiKeyPair);
	
	AccountViewAdapter accountViewAdapter = new AccountViewAdapter(this, pairs);
	accountListView.setAdapter(accountViewAdapter);
	
	setContentView(accountLayout);
	
	super.onCreate(savedInstanceState);
}
 
Example 5
Project: CCDownload   File: DownloadFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	activity = getActivity();
	context = activity.getApplicationContext();
	receiver = new DownloadedReceiver();
	activity.registerReceiver(receiver, new IntentFilter(ConfigUtil.ACTION_DOWNLOADING));
	
	RelativeLayout downloadRelativeLayout = new RelativeLayout(context);
	downloadRelativeLayout.setBackgroundColor(Color.WHITE);
	downloadRelativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	
	downloadListView = new ListView(context);
	downloadListView.setPadding(10, 10, 10, 10);
	downloadListView.setDivider(getResources().getDrawable(R.drawable.line));
	LayoutParams listViewLayout = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	downloadRelativeLayout.addView(downloadListView, listViewLayout);
	
	// 生成动态数组,加入数据
	pairs = new ArrayList<Pair<String,Integer>>();
	for (int i = 0; i < downloadVideoIds.length; i++) {
		Pair<String, Integer> pair = new Pair<String, Integer>(downloadVideoIds[i], R.drawable.download);
		pairs.add(pair);
	}

	downloadListViewAdapter = new DownloadListViewAdapter(context, pairs);
	downloadListView.setAdapter(downloadListViewAdapter);
	downloadListView.setOnItemClickListener(onItemClickListener);

	service = new Intent(context, DownloadService.class);
	activity.bindService(service, serviceConnection, Context.BIND_AUTO_CREATE);
	
	initDownloaderHashMap();
	
	return downloadRelativeLayout;
}
 
Example 6
Project: CCDownload   File: DownloadingFragment.java   View Source Code Vote up 5 votes
private void initView(RelativeLayout view ){
	view.setBackgroundColor(Color.WHITE);
	LayoutParams downloadingLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	downloadingListView = new ListView(context);
	downloadingListView.setPadding(10, 10, 10, 10);
	downloadingListView.setDivider(getResources().getDrawable(R.drawable.line));
	view.addView(downloadingListView, downloadingLayoutParams);
	
	downloadingListView.setOnItemClickListener(onItemClickListener);
	downloadingListView.setOnCreateContextMenuListener(onCreateContextMenuListener);
	
}
 
Example 7
Project: CCDownload   File: PlayFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	context = getActivity().getApplicationContext();
	RelativeLayout playLayout = new RelativeLayout(context);
	playLayout.setBackgroundColor(Color.WHITE);
	LayoutParams playLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	playLayout.setLayoutParams(playLayoutParams);
	
	playListView = new ListView(context);
	playListView.setDivider(getResources().getDrawable(R.drawable.line));
	playListView.setDividerHeight(2);
	playListView.setPadding(10, 10, 10, 10);
	LayoutParams playListLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	playLayout.addView(playListView, playListLayoutParams);

	// 生成动态数组,加入数据
	pairs = new ArrayList<Pair<String,Integer>>();
	for (int i = 0; i < playVideoIds.length; i++) {
		Pair<String, Integer> pair = new Pair<String, Integer>(playVideoIds[i], R.drawable.play);
		pairs.add(pair);
	}

	videoListViewAdapter = new VideoListViewAdapter(context, pairs);
	playListView.setAdapter(videoListViewAdapter);
	playListView.setOnItemClickListener(onItemClickListener);

	return playLayout;
}
 
Example 8
Project: quickblox-android   File: SettingsFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);
    if (v != null) {
        ListView lv = (ListView) v.findViewById(android.R.id.list);
        lv.setPadding(0, 0, 0, 0);
    }
    return v;
}
 
Example 9
Project: MainCalendar   File: WeekPicker.java   View Source Code Vote up 5 votes
@Override
@NonNull
protected LinearLayout makeCenterView() {
    LinearLayout rootLayout = new LinearLayout(activity);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    rootLayout.setOrientation(LinearLayout.VERTICAL);

    mListView = new ListView(activity);
    mListView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    mListView.getLayoutParams().height = screenHeightPixels/4;
    mListView.setPadding(30, 10, 30, 10);
    // 去掉分割线
    mListView.setDividerHeight(0);
    mListView.setAdapter(mWeekAdapter);
    rootLayout.addView(mListView);

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1,
                                int arg2, long arg3) {
            // 取得ViewHolder对象,这样就省去了通过层层的findViewById去实例化我们需要的cb实例的步骤
            WeekAdapter.ViewHolder holder = (WeekAdapter.ViewHolder) arg1.getTag();
            // 改变CheckBox的状态
            holder.cb.toggle();
            // 将CheckBox的选中状况记录下来
            mWeekAdapter.setIsSelected(arg2, holder.cb.isChecked());
        }
    });
    setTitleText(mTitle);
    return rootLayout;
}