當前位置: 首頁>>代碼示例>>Java>>正文


Java GridLayout.addView方法代碼示例

本文整理匯總了Java中android.widget.GridLayout.addView方法的典型用法代碼示例。如果您正苦於以下問題:Java GridLayout.addView方法的具體用法?Java GridLayout.addView怎麽用?Java GridLayout.addView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.GridLayout的用法示例。


在下文中一共展示了GridLayout.addView方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createOptionIcon

import android.widget.GridLayout; //導入方法依賴的package包/類
private View createOptionIcon(GridLayout parent, int rowIndex, boolean editIconExists) {
    // The icon has a pre-defined width.
    ImageView optionIcon = new ImageView(parent.getContext());
    optionIcon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    optionIcon.setBackgroundResource(R.drawable.payments_ui_logo_bg);
    optionIcon.setImageDrawable(mOption.getDrawableIcon());
    optionIcon.setMaxWidth(mIconMaxWidth);

    // Place option icon at column three if no edit icon.
    int columnStart = editIconExists ? 2 : 3;
    GridLayout.LayoutParams iconParams = new GridLayout.LayoutParams(
            GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
            GridLayout.spec(columnStart, 1));
    iconParams.topMargin = mVerticalMargin;
    parent.addView(optionIcon, iconParams);

    optionIcon.setOnClickListener(OptionSection.this);
    return optionIcon;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:20,代碼來源:PaymentRequestSection.java

示例2: addStripes

import android.widget.GridLayout; //導入方法依賴的package包/類
private void addStripes() {
    GridLayout gridLayout=new GridLayout(this);
    RelativeLayout.LayoutParams gl=new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    gridLayout.setColumnCount(gridColumnCount);
    gridLayout.setLayoutParams(gl);

    parentLayout.addView(gridLayout);

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(deviceWidth/2,deviceHeight/3);
    Log.i(Tag,"addStripes called");

    for (int i = 0; i < stripeCount; i++) {
        stripe[i] = new Stripes(this,i);
        stripe[i].setLayoutParams(layoutParams);
        gridLayout.addView(stripe[i]);
    }

    addColors();
}
 
開發者ID:YDrall,項目名稱:ColorTap,代碼行數:21,代碼來源:GameActivity.java

示例3: onCreate

import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_property_animation);

    mBtnXXml = (ImageButton) findViewById(R.id.btn_x_xml);
    mBtnXCode = (ImageButton) findViewById(R.id.btn_x_code);
    mGridLayout = (GridLayout) findViewById(R.id.grid);

    findViewById(R.id.btn_grid).setOnClickListener(this);
    mBtnXXml.setOnClickListener(this);
    mBtnXCode.setOnClickListener(this);

    // GridLayoutにボタンを複數追加
    int maxChild = mGridLayout.getRowCount() * mGridLayout.getColumnCount();
    for (int i = 0; i < maxChild; i++) {
        Button button = (Button) getLayoutInflater().inflate(R.layout.activity_main_button, mGridLayout, false);
        button.setText(i + "");
        mGridLayout.addView(button);
    }
}
 
開發者ID:yokmama,項目名稱:honki_android,代碼行數:22,代碼來源:PropertyAnimationActivity.java

示例4: addTableHeader

import android.widget.GridLayout; //導入方法依賴的package包/類
private GridLayout addTableHeader( String... headers ) {

      GridLayout gridLayout = new GridLayout( getContext() );
      gridLayout.setBackgroundResource( R.color.grey_faint );
      int rowNum = 0;
      int columnNum = 0;
      for ( String header : headers ) {

         RobotoTextView headerText = new RobotoTextView( getContext() );
         headerText.setTextAppearance( getContext(), R.style.CardKey );
         headerText.setText( header );

         Spec rowspecs = GridLayout.spec( rowNum, 1 );
         Spec colspecs = GridLayout.spec( columnNum, 1 );
         GridLayout.LayoutParams params = new GridLayout.LayoutParams( rowspecs, colspecs );
         params.setGravity( Gravity.CENTER_HORIZONTAL );
         params.setMargins( getContext().getResources().getDimensionPixelSize( R.dimen.column_padding ), 0, getContext().getResources().getDimensionPixelSize( R.dimen.column_padding ), 0 );

         gridLayout.addView( headerText, params );

         columnNum++;
      }

      return gridLayout;
   }
 
開發者ID:hoolrory,項目名稱:VideoInfoViewer,代碼行數:26,代碼來源:BoxInfoView.java

示例5: addTableRow

import android.widget.GridLayout; //導入方法依賴的package包/類
private void addTableRow( GridLayout gridLayout, String... columns ) {
   int rowNum = gridLayout.getRowCount();

   int columnNum = 0;
   for ( String column : columns ) {

      RobotoTextView columnText = new RobotoTextView( getContext() );
      columnText.setTextAppearance( getContext(), R.style.CardValue );
      columnText.setText( column );

      Spec rowspecs = GridLayout.spec( rowNum, 1 );
      Spec colspecs = GridLayout.spec( columnNum, 1 );
      GridLayout.LayoutParams params = new GridLayout.LayoutParams( rowspecs, colspecs );
      params.setGravity( Gravity.CENTER_HORIZONTAL );

      gridLayout.addView( columnText, params );

      columnNum++;
   }
}
 
開發者ID:hoolrory,項目名稱:VideoInfoViewer,代碼行數:21,代碼來源:BoxInfoView.java

示例6: onCreate

import android.widget.GridLayout; //導入方法依賴的package包/類
/**
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game);

    estado = Estado.NAO_VIRADA;
    grid = (GridLayout) findViewById(R.id.grid);
    grid.setColumnCount(4);

    final int NUMBER_OF_CARDS = this.resources.length * 2;

    cards = new ArrayList<>(NUMBER_OF_CARDS);

    for (int i = 0; i < NUMBER_OF_CARDS; i++) {
        ImageButton btn = new ImageButton(this);
        btn.setImageResource(R.mipmap.ic_costas);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(150, 150);
        btn.setLayoutParams(layoutParams);
        btn.setOnClickListener(this);
        btn.setTag(new CardInfo(resources[i % 8]));
        cards.add(btn);
    }

    Collections.shuffle(cards);

    for(ImageButton button : this.cards ){
        grid.addView(button);
    }
}
 
開發者ID:Mr-Holmes,項目名稱:Jogo-da-Memoria,代碼行數:33,代碼來源:Game.java

示例7: onCreate

import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.choose_videos);
	cameraMain2 = this;
	videos = (GridLayout) findViewById(R.id.videos);
	nextView = (TextView) findViewById(R.id.video_choose_next);
	cancleView = (TextView) findViewById(R.id.video_choose_cancel);
	nextView.setOnClickListener(this);
	cancleView.setOnClickListener(this);
	numView = (ImageView) findViewById(R.id.video_choose_num);
	// 最好再檢查一下係統版本。
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
		Boolean isHave = checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, 1);
		if (isHave == false)
			this.finish();
	}
	width = this.getWindowManager().getDefaultDisplay().getWidth() / 3;
	bitmapDefault = readBitMap(CameraMain2.this, R.drawable.icon);
	bitmapDefault = StaticMethod.getThumImg(bitmapDefault, width);
	showProgress("", msg);
	ImageView imageView = new ImageView(CameraMain2.this);
	imageView.setTag(imageId);
	imageView.setOnClickListener(CameraMain2.this);
	imageView.setLayoutParams(new LayoutParams(width, width));
	imageView.setImageResource(R.drawable.add_image);
	videos.addView(imageView);

	handler.postDelayed(new Runnable() {

		@Override
		public void run() {
			File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "");
			getVideoFile(file, 0);//
			threadLoadThum.start();
			hideProgress();
		}
	}, 100);

}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:42,代碼來源:CameraMain2.java

示例8: createEditIcon

import android.widget.GridLayout; //導入方法依賴的package包/類
private View createEditIcon(GridLayout parent, int rowIndex) {
    View editorIcon = LayoutInflater.from(parent.getContext())
                              .inflate(R.layout.payment_option_edit_icon, null);

    // The icon floats to the right of everything.
    GridLayout.LayoutParams iconParams = new GridLayout.LayoutParams(
            GridLayout.spec(rowIndex, 1, GridLayout.CENTER), GridLayout.spec(3, 1));
    iconParams.topMargin = mVerticalMargin;
    parent.addView(editorIcon, iconParams);

    editorIcon.setOnClickListener(OptionSection.this);
    return editorIcon;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:14,代碼來源:PaymentRequestSection.java

示例9: onCreate

import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_animations);

    // Grayscale filter used on all thumbnails
    ColorMatrix grayMatrix = new ColorMatrix();
    grayMatrix.setSaturation(0);
    ColorMatrixColorFilter grayscaleFilter = new ColorMatrixColorFilter(grayMatrix);
    
    mGridLayout = (GridLayout) findViewById(R.id.gridLayout);
    mGridLayout.setColumnCount(3);
    mGridLayout.setUseDefaultMargins(true);
    
    // add all photo thumbnails to layout
    Resources resources = getResources();
    ArrayList<PictureData> pictures = mBitmapUtils.loadPhotos(resources);
    for (int i = 0; i < pictures.size(); ++i) {
        PictureData pictureData = pictures.get(i);
        BitmapDrawable thumbnailDrawable =
                new BitmapDrawable(resources, pictureData.thumbnail);
        thumbnailDrawable.setColorFilter(grayscaleFilter);
        ImageView imageView = new ImageView(this);
        imageView.setOnClickListener(thumbnailClickListener);
        imageView.setImageDrawable(thumbnailDrawable);
        mPicturesData.put(imageView, pictureData);
        mGridLayout.addView(imageView);
    }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:30,代碼來源:ActivityAnimations.java

示例10: addAppToIconSheet

import android.widget.GridLayout; //導入方法依賴的package包/類
private void addAppToIconSheet(GridLayout iconSheet, AppLauncher app, int pos, boolean reuse) {
    if (app != null) {
        try {
            if ((app.isWidget() && isAppInstalled(app.getPackageName())) || mLaunchApp.isValidActivity(app)) {
                ViewGroup item = getLauncherView(app, false, reuse);
                if (item != null) {
                    if (!app.iconLoaded()) {
                        app.loadAppIconAsync(this, mPackageMan);
                    }
                    ViewGroup parent = (ViewGroup) item.getParent();
                    if (parent != null) parent.removeView(item);
                    GridLayout.LayoutParams lp = getAppLauncherLayoutParams(iconSheet, app);
                    iconSheet.addView(item, pos, lp);
                    return;
                }
            } else {
                db().deleteApp(app.getComponentName());
                Log.d(TAG, "removed " + app.getPackageName() + " " + app.getActivityName() + ":activity not valid.");
            }
        } catch (Exception e) {
            Log.e(TAG, "exception adding icon to sheet", e);
            Toast.makeText(this,"Couldn't place icon: " + e.getMessage(), Toast.LENGTH_LONG).show();
        }
    } else {
        Log.d(TAG, "Not showing recent: Null.");
    }

}
 
開發者ID:quaap,項目名稱:LaunchTime,代碼行數:29,代碼來源:MainActivity.java

示例11: createAbout

import android.widget.GridLayout; //導入方法依賴的package包/類
private void createAbout() {
    innerWrapperLayout.setTranslationY(-30);

    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) innerWrapperLayout.getLayoutParams();
    layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;


    /* -------------- */
    /* New components */

    /* This inner wrapper is needed for gravity to work correctly */
    FrameLayout aboutInnerWrapperLayout = new FrameLayout(activity);
    aboutInnerWrapperLayout.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    aboutInnerWrapperLayout.setTranslationY(-60);

    /* All information should be in this gridLayout */
    GridLayout aboutLayout = new GridLayout(activity);
    GridLayout.LayoutParams aboutLayoutParams = new GridLayout.LayoutParams();
    aboutLayoutParams.setGravity(Gravity.CENTER);
    aboutLayout.setLayoutParams(aboutLayoutParams);

    /* Scroll view in case the content is too big */
    ScrollView scrollView = new ScrollView(activity);
    scrollView.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    scrollView.setBackgroundColor(Misc.getColor(activity, R.color.colorPrimary));
    scrollView.setPadding(0, 120, 0, 120);

    /* Format with HTML. This is way easier for specific tasks. Warning, colors in the WebView are hardcoded. */
    WebView aboutText = new WebView(activity);
    aboutText.setBackgroundColor(Color.TRANSPARENT);
    aboutText.loadData(activity.getString(R.string.about), "text/html", "utf-8");

    /* Back button */
    TextView backButton = new TextView(activity);
    backButton.setTextColor(Misc.getColor(activity, R.color.colorAccent));
    backButton.setText("back");
    backButton.setPadding(0, 0, 0, 70);
    backButton.setGravity(Gravity.CENTER);
    backButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36);
    backButton.setTypeface(Typeface.create("sans-serif-thin", Typeface.NORMAL));
    backButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setCallback(0);
        }
    });


    /* -------------------------- */
    /* Bundle everything together */

    aboutLayout.addView(backButton, new GridLayout.LayoutParams(GridLayout.spec(0, GridLayout.CENTER), GridLayout.spec(0, GridLayout.CENTER)));
    aboutLayout.addView(aboutText, new GridLayout.LayoutParams(GridLayout.spec(1, GridLayout.CENTER), GridLayout.spec(0, GridLayout.CENTER)));

    scrollView.addView(aboutLayout);
    aboutInnerWrapperLayout.addView(scrollView);

    outerWrapperLayout.addView(aboutInnerWrapperLayout);
}
 
開發者ID:intxcc,項目名稱:OwnTrack,代碼行數:60,代碼來源:BootScreen.java

示例12: onCreate

import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    findViewById(R.id.button).setOnClickListener(this);
    gridLayout = (GridLayout) findViewById(R.id.gridlayout);
    lengths = getLengths();
    tester = getTester();
    labels = getResources().getStringArray(getLabelsArray());
    for (int i = 0; i < labels.length; i++) {
        TextView valueView = new TextView(TestActivity.this);
        valueView.setText(labels[i]);
        gridLayout.addView(valueView);
    }
}
 
開發者ID:PacktPublishing,項目名稱:Android-High-Performance-Programming,代碼行數:15,代碼來源:TestActivity.java

示例13: setColumnCount

import android.widget.GridLayout; //導入方法依賴的package包/類
private void setColumnCount(GridLayout answerarea, int count) {
    List<View> kids = new ArrayList<>();
    for(int i = 0; i< answerarea.getChildCount(); i++) {
        kids.add(answerarea.getChildAt(i));
    }
    answerarea.removeAllViews();

    answerarea.setColumnCount(count);

    for (View k: kids) {
        k.setLayoutParams(new GridLayout.LayoutParams());
        answerarea.addView(k);
    }
}
 
開發者ID:quaap,項目名稱:Primary,代碼行數:15,代碼來源:StdGameActivity.java

示例14: addTextView

import android.widget.GridLayout; //導入方法依賴的package包/類
private void addTextView(GridLayout viewg, String text, float fsize, int lpadding) {
    TextView tview = new TextView(this);
    tview.setTextSize(fsize);
    tview.setPadding(lpadding + 16, 6, 6, 6);
    tview.setText(text);
    viewg.addView(tview);
}
 
開發者ID:quaap,項目名稱:Primary,代碼行數:8,代碼來源:ScoresActivity.java

示例15: onCreate

import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	GridLayout layout = new GridLayout(this);
	ScrollView scroll = new ScrollView(this);
	scroll.addView(layout);
	setContentView(scroll);
	
	try {
		String [] list = getAssets().list("images");
		
		// count tga images
		int count = 0;
		for(int i=0; i<list.length; i++) {
			if(list[i].endsWith(".tga")) count++;
		}
		
		layout.setColumnCount(3);
		layout.setRowCount(count/3);
		
		// create tga image view
		for(int i=0; i<list.length; i++) {
			if(list[i].endsWith(".tga")) {
				LinearLayout view = createTGAView(list[i]);
				if(view != null) layout.addView(view);
			}
		}
		
	}
	catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:npedotnet,項目名稱:TGAReader,代碼行數:35,代碼來源:TGABitmapViewerActivity.java


注:本文中的android.widget.GridLayout.addView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。