View setId - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for View setId method.

This code example shows how to use the following methods:setId, setLayoutParams, setOrientation
        void setContentToFragment(T fragment) {
            if (fragment == null) {
                fragment = createFragment();
            } 
 
            LinearLayout layout = new LinearLayout(this);
            layout.setOrientation(LinearLayout.VERTICAL);
            layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.FILL_PARENT));
            layout.setId(FRAGMENT_ID);
 
            getSupportFragmentManager().beginTransaction() 
                    .add(FRAGMENT_ID, fragment)
                    .commit(); 
 
            fragmentId = FRAGMENT_ID;
 
            setContentView(layout);
        } 
 
9
CodeRank
This code example shows how to use the following methods:setId, setLayoutParams, setIndeterminate, setVisibility
This code example shows how to use the following methods:setId, setVisibility, setGravity, setPadding, setText
This code example shows how to use the following methods:setId, setLayoutParams
    if ((row == null) || (row.findViewById(1337) == null)) {
      RelativeLayout layout = new RelativeLayout(activity);
      layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, ListView.LayoutParams.WRAP_CONTENT));
      row = layout;
       
      WebView webView = new WebView(activity);
      webView.setId(1337);
      RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); 
      float scale = activity.getResources().getDisplayMetrics().density;
      boolean leftPadding = (parent.getTag().equals("right"));
      params.setMargins((int)(20 * scale) * (leftPadding ? 2 : 1), (int)(0 * scale), (int)(20 * scale), 0);
      webView.setLayoutParams(params);
      layout.addView(webView);
    } 
       
    WebView webView = (WebView)row.findViewById(1337);
 
    String item = (String)getItem(position);
    if (item.trim().length() == 0) {
      webView.loadData("<em>No information.</em>", "text/html", "utf-8");
8
CodeRank
This code example shows how to use the following methods:getId, setId, setLayoutParams
RelativeLayout listItemLayout = new RelativeLayout( activity );
		listItemLayout.setPadding( 5, 5, 5, 5 );
		 
		TextView label = new TextView( activity );
		ImageView icon = new ImageView( activity );
		icon.setId( 100 );
		 
		RelativeLayout.LayoutParams labelParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT );
		labelParams.addRule( RelativeLayout.ALIGN_PARENT_RIGHT );
		labelParams.addRule( RelativeLayout.RIGHT_OF, icon.getId( ) );
		labelParams.addRule( RelativeLayout.CENTER_VERTICAL );
		labelParams.setMargins( 5, 0, 0, 5 );
		label.setLayoutParams( labelParams );
		 
		label.setTextSize( 15.0f );
		 
		RelativeLayout.LayoutParams iconParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT );
		iconParams.addRule( RelativeLayout.ALIGN_PARENT_LEFT );
		iconParams.addRule( RelativeLayout.CENTER_VERTICAL );

8
CodeRank
This code example shows how to use the following methods:setId
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mHelper = new SlidingActivityHelper(this);
		mHelper.onCreate(savedInstanceState);
		ListView listView = new ListView(this);
		listView.setId(android.R.id.list);
		setContentView(listView);
	} 
 
	/* (non-Javadoc) 
	 * @see android.app.Activity#onPostCreate(android.os.Bundle) 
	 */ 
	@Override 
	public void onPostCreate(Bundle savedInstanceState) {
		super.onPostCreate(savedInstanceState);
		mHelper.onPostCreate(savedInstanceState);
	} 
 
	/* (non-Javadoc) 
8
CodeRank
This code example shows how to use the following methods:setId, setGravity
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        FrameLayout root = new FrameLayout(getActivity());
 
        TextView tv = new TextView(getActivity());
        tv.setId(INTERNAL_EMPTY_ID);
        tv.setGravity(Gravity.CENTER);
        root.addView(tv, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
 
        ExpandableListView lv = new ExpandableListView(getActivity());
        lv.setId(android.R.id.list);
        lv.setDrawSelectorOnTop(false);
        root.addView(lv, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
 
        ListView.LayoutParams lp = new ListView.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
        root.setLayoutParams(lp);
8
CodeRank
This code example shows how to use the following methods:setId, setLayoutParams, setGravity, setText, setTextColor
This code example shows how to use the following methods:setId, setPadding
				FrameLayout.LayoutParams.MATCH_PARENT));
	} 
 
	@Override 
	public void setContentView(final View view, final ViewGroup.LayoutParams params) {
		final ListView lv = new ListView(this);
		final Resources res = getResources();
		final float density = res.getDisplayMetrics().density;
		final int padding = (int) density * 16;
		lv.setId(android.R.id.list);
		lv.setPadding(padding, 0, padding, 0);
		super.setContentView(lv, params);
	} 
 
	public void setTheme() { 
		final SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
		final boolean is_dark_theme = preferences.getBoolean(PREFERENCE_KEY_DARK_THEME, false);
		final boolean solid_color_background = preferences.getBoolean(PREFERENCE_KEY_SOLID_COLOR_BACKGROUND, false);
		setTheme(is_dark_theme ? R.style.Theme_Twidere : R.style.Theme_Twidere_Light);
		if (solid_color_background) {
7
CodeRank
This code example shows how to use the following methods:setId, setLayoutParams
	 * 
	 * @return the widget that holds the actual tabs. 
	 */ 
	private TabWidget createTabWidget(Activity activity)
	{ 
        TabWidget tabWidget = new TabWidget( activity );
        tabWidget.setId( android.R.id.tabs );
        LinearLayout.LayoutParams tabWidgetParams =
			new LinearLayout.LayoutParams(
        				LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT );
        tabWidgetParams.weight = 0;
        tabWidget.setLayoutParams( tabWidgetParams );
 
        return tabWidget;
	} 
 
	public class TabChangeListener implements OnTabChangeListener
	{ 
 
		private int m_tabScreenHandle;
7
CodeRank

Related View setId Questions & Answers:

setId Method Overview
Sets the identifier for this view.
See Code Examples for other Android View Methods: