Java Code Examples for android.widget.LinearLayout.setFocusable()

The following are Jave code examples for showing how to use setFocusable() of the android.widget.LinearLayout 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: LauncherTV   File: ApplicationFragment.java   View Source Code Vote up 4 votes
private void createApplications() {
	mContainer.removeAllViews();

	mGridX = mSetup.getGridX();
	mGridY = mSetup.getGridY();

	if (mGridX < 2)
		mGridX = 2;
	if (mGridY < 1)
		mGridY = 1;

	int marginX = Utils.getPixelFromDp(getContext(), mSetup.getMarginX());
	int marginY = Utils.getPixelFromDp(getContext(), mSetup.getMarginY());

	boolean showNames = mSetup.showNames();

	mApplications = new ApplicationView[mGridY][mGridX];

	int position = 0;
	for (int y = 0; y < mGridY; y++) {
		LinearLayout ll = new LinearLayout(getContext());
		ll.setOrientation(LinearLayout.HORIZONTAL);
		ll.setGravity(Gravity.CENTER_VERTICAL);
		ll.setFocusable(false);
		ll.setLayoutParams(new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT, 0, 1
		));

		for (int x = 0; x < mGridX; x++) {
			ApplicationView av = new ApplicationView(getContext());
			av.setOnClickListener(this);
			av.setOnLongClickListener(this);
			av.setOnMenuOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					onLongClick(v);
				}
			});
			av.setPosition(position++);
			av.showName(showNames);
			if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
				av.setId(0x00FFFFFF + position);
			} else {
				av.setId(View.generateViewId());
			}
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
			lp.setMargins(marginX, marginY, marginX, marginY);
			av.setLayoutParams(lp);
			ll.addView(av);
			mApplications[y][x] = av;
		}
		mContainer.addView(ll);
	}

	updateApplications();
	setApplicationOrder();
}