Search Results

Search found 118 results on 5 pages for 'tablerow'.

Page 1/5 | 1 2 3 4 5  | Next Page >

  • android: two issues using Tablerow+TextView in Tablelayout

    - by Yang
    I am using Tablerow+TextView to make a simple view for blog posts and their replies. In each TableRow I put a TextView in. Now I have two issues: The text which is longer than the screen won't automatically wrap up to be multi-line. Is it by design of TableRow? I've already set tr_content.setSingleLine(false); [update] This has been addressed, I think I should change Fill_parent to be Wrap_content in textView.tr_author_time.setLayoutParams(new LayoutParams( LayoutParams.**WRAP_CONTENT**, LayoutParams.WRAP_CONTENT)); The Table won't scroll like ListView. My rows are more than the screen size. I expect the table could be scrolled down for viewing just like ListView. Is that possible? Here is my code: TableLayout tl = (TableLayout) findViewById(R.id.article_content_table); TextView tr_title = new TextView(this); TextView tr_author_time = new TextView(this); TextView tr_content = new TextView(this); TableRow tr = new TableRow(this); for(int i = 0; i < BlogPost.size(); i++){ try{ // add the author, time tr = new TableRow(this); /////////////////add author+time row BlogPost article = mBlogPost.get(i); tr_author_time = new TextView(this); tr_author_time.setText(article.author+"("+ article.post_time+")"); tr_author_time.setTextColor(getResources().getColor(R.color.black)); tr_author_time.setGravity(0x03); tr_author_time.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); tr.addView(tr_author_time); tl.addView(tr,new TableLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); ////////////////////// then add content row tr = new TableRow(this); tr_content = new TextView(this); tr_content.setText(article.content); tr_content.setSingleLine(false); tr_content.setGravity(0x03); tr_content.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); tr.addView(tr_content); tr.setBackgroundResource(R.color.white); tl.addView(tr,new TableLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); }

    Read the article

  • android: tablerow mixed with columns and multiline text

    - by Yang
    I am trying to have a tablelayout contains several tablerows. One of the rows contains 4 buttons, while the second row contains a very long text. However, the width of the button stretches with the text in the second row. Is there anyway to prevent this? http://img684.imageshack.us/i/tableview1.jpg/ http://img521.imageshack.us/i/tableview2.jpg/ Here is my xml file: (somehow this website is not friendly to xml file) AbsoluteLayout android:id="@+id/widget0" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" TableLayout android:id="@+id/widget28" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_x="0px" android:layout_y="10px" TableRow android:id="@+id/widget29" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" Button android:id="@+id/widget30" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" Button android:id="@+id/widget31" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" Button android:id="@+id/widget32" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" Button android:id="@+id/widget33" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" TableRow android:id="@+id/widget35" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" TextView android:id="@+id/widget40" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextViewTextViewTextViewTextViewTextViewTextView"

    Read the article

  • Android TableRow RelativeLayout Issue

    - by phogel
    I have the following <TableRow xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/admin_row" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:background="@color/silver"> I dynamically populate the table but with the relative layout colored silver it only spans about 3/4 of the table row. If I put a LinearLayout with horizontal orientation it spans completely but if I change it to vertical the same problem occurs. I need a relative layout in the table row because I need to something like this: Value Detail MoreDetail. Any ideas on getting the relative layout to span the table row?

    Read the article

  • focusable row inside table android

    - by Nikitas
    Hello guys, i have in xml a ScrollView which includes one TableLayout. My question is if it's possible to have a focusable row every time i click on it. Here is my xml code: <ScrollView android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TableLayout android:id="@+id/table2" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TableRow> <RelativeLayout android:id="@+id/rowlayout" android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="@drawable/rowbackground2" > <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon_code_contact" android:padding="7dip" android:layout_alignParentLeft="true" /> <TextView android:id="@+id/contacts" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="bold" android:text="Contacts" android:textColor="#000" android:textSize="18dip" android:layout_toRightOf="@id/icon" android:paddingTop="10dip" /> </RelativeLayout> </TableRow> <TableRow> <Button android:id="@+id/contacts_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/contact_button" /> </TableRow> I have already tried the "focusable="true"" and "focusableInTouchMode="true"" but nothing happened.. thanks in advance

    Read the article

  • Error reading values from dynamically created table rows in Android

    - by jaymo
    So I have a couple of dynamically created tablerows.Each TableRow has a couple of Textviews.I have a button that on clicked should get all the values of the second and third textviews in each Tablerow in the Table. I have tried to do this using the code below mSubmitOrders.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if(mTable.getChildCount()>1){ for(int i = 0; i < mTable.getChildCount(); i++){ TableRow tr = (TableRow)mTable.getChildAt(i); TextView code = (TextView) tr.getChildAt(1); TextView quantity = (TextView) tr.getChildAt(2); String Scode = code.getText().toString(); Log.i("TAG", Scode); String Squantity = quantity.getText().toString(); Log.i("TAG", Squantity); } } But I get the below errors (Logcat below). Assistance required 10-22 09:00:16.345: E/AndroidRuntime(4495): FATAL EXCEPTION: main 10-22 09:00:16.345: E/AndroidRuntime(4495): java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView 10-22 09:00:16.345: E/AndroidRuntime(4495): at com.symetry.myitprovider.ui.actual$4.onClick(actual.java:173) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.view.View.performClick(View.java:3131) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.view.View$PerformClick.run(View.java:12035) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.os.Handler.handleCallback(Handler.java:587) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.os.Handler.dispatchMessage(Handler.java:92) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.os.Looper.loop(Looper.java:132) 10-22 09:00:16.345: E/AndroidRuntime(4495): at android.app.ActivityThread.main(ActivityThread.java:4123) 10-22 09:00:16.345: E/AndroidRuntime(4495): at java.lang.reflect.Method.invokeNative(Native Method) 10-22 09:00:16.345: E/AndroidRuntime(4495): at java.lang.reflect.Method.invoke(Method.java:491) 10-22 09:00:16.345: E/AndroidRuntime(4495): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844) 10-22 09:00:16.345: E/AndroidRuntime(4495): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 10-22 09:00:16.345: E/AndroidRuntime(4495): at dalvik.system.NativeStart.main(Native Method) EDIT: I have modified my code and now there is no error..but its not working as needed.. The new code is as below.. mSubmitOrders.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if(mTable.getChildCount()>1){ for(int i = 0; i < mTable.getChildCount(); i++){ //TODO: Figure out how to do this well LinearLayout LL = (LinearLayout)mTable.getChildAt(i); View x = ((View)(LL.getParent()).getParent()); Log.i("TAG", "Past view"); TextView code = (TextView)((ViewGroup) x).getChildAt(2); String Scode = code.getText().toString(); Log.i("TAG", Scode); } But thing is its not getting the texview from TableLayout's Table Row..its getting a different one...the one I have circled in the picture ![Error]:http://semasoftltd.com/error.png

    Read the article

  • ASP.net access controls dynamically

    - by c11ada
    hey all, i have a table which looks similar to this <asp:TableRow><asp:TableCell>Question 1</asp:TableCell><asp:TableCell ID ="Question1Text"></asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell ColumnSpan="2"> <asp:RadioButtonList ID="RadioButtonList1" runat="server"><asp:ListItem>Yes</asp:ListItem><asp:ListItem>No</asp:ListItem> </asp:RadioButtonList> </asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell> <asp:TextBox ID="TextBox1" TextMode="MultiLine" runat="server"></asp:TextBox></asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell>Question 2</asp:TableCell><asp:TableCell ID ="Question2Text"></asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell ColumnSpan="2"> <asp:RadioButtonList ID="RadioButtonList2" runat="server"><asp:ListItem>Yes</asp:ListItem><asp:ListItem>No</asp:ListItem> </asp:RadioButtonList> </asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell> <asp:TextBox ID="TextBox2" TextMode="MultiLine" runat="server"></asp:TextBox></asp:TableCell></asp:TableRow> i want to be able to systematically acces table cells with ID's for example for (int i = 1; i<3 ; i++) { // i want to be able to access the table cell with the ID Question1Text then Question2Text and so on } is this even possible ??

    Read the article

  • How to automatically resize an EditText widget (with some attributes) in a TableLayout

    - by steff
    Hi everyone, I have a layout issue. What I do is this: create TableLayout in xml with zero children: <TableLayout android:id="@+id/t_layout_contents" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/l_layout_tags" android:stretchColumns="1" android:paddingLeft="5dip" android:paddingRight="5dip" /> Insert first row programmatically in onCreate(): tLayoutContents = (TableLayout)findViewById(R.id.t_layout_contents); NoteElement nr_1 = new NoteElement(this); tLayoutContents.addView(nr_1); Class "NoteElement" extends TableRow. The 1st row just consists of a blank ImageView as a placeholder and an EditText to enter text. NoteElement's constructor looks like this: public NoteElement(Context c) { super(c); this.context = c; defaultText = c.getResources().getString(R.string.create_note_help_text); imageView = new ImageView(context); imageView.setImageResource(android.R.color.transparent); LayoutParams params = new LayoutParams(0); imageView.setLayoutParams(params); addView(imageView); addView(addTextField()); } Method addTextField() specifies the attributes for the EditText widget: private EditText addTextField() { editText = new EditText(context); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); editText.setMinLines(4); editText.setRawInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); editText.setHint(R.string.create_note_et_blank_text); editText.setAutoLinkMask(Linkify.ALL); editText.setPadding(5, 0, 0, 0); editText.setGravity(Gravity.TOP); editText.setVerticalScrollBarEnabled(true); LayoutParams params = new LayoutParams(1); editText.setLayoutParams(params); return editText; } So far, so good. But my problem occurs as soon as the available space for the chars is depleted. The EditText does not resize itself but switches to a single line EditText. I am desperatly looking for a way in which the EditText resizes itself in its height dynamically, being dependant on the inserted text length. Does anyone have a hint on this? Thanks & regards, steff

    Read the article

  • CSS3 transition on table row using height property

    - by Alexis Leclerc
    I have an HTML table displaying some information with a few rows. On each row, the user can click to reveal some additional rows that contains information related to the clicked row. Something like this: While the additional rows are being created with an AJAX request, a loading row is inserted right after the clicked row : Currently, everything works perfectly (drill down style), but I would like to add some animation to the loading row. I found a question ( this one ) that has a JSFiddle showing kind of what I want ( this fiddle ). I tried to implement something similar with CSS3 transitions, but I can't get it to work. Here's my simulated attempt ( fiddle only for deployment of the loading row ) using these transitions : -webkit-transition: height 0.1s ease-in-out; -moz-transition: height 0.1s ease-in-out; -ms-transition: height 0.1s ease-in-out; -o-transition: height 0.1s ease-in-out; transition: height 0.1s ease-in-out; Any thought on why my fiddle doesn't do any animation? Any other methods you would propose? Thanks!

    Read the article

  • Stretching across 2 rows in Table Layout

    - by Will03uk
    How do I stretch across 2 columns in the Table Layout. I have 2 rows with a label and edit text on 1 row and I want to have a single button stretch across the whole second row. <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="#000000" android:stretchColumns="1"> <TableRow> <TextView android:text = "Name: " /> <EditText android:id = "@+id/txtAddName" android:gravity = "right" android:layout_width = "fill_parent" /> </TableRow> <TableRow> <TextView android:text = "Phone: " /> <EditText android:id = "@+id/txtAddPhone" android:gravity = "right" android:layout_width = "fill_parent" /> </TableRow> <TableRow> <Button android:id = "@+id/btnAdd" android:text = "Add Entrie" android:layout_width = "fill_parent" /> </TableRow> <TableRow> <Button android:id = "@+id/btnShow" android:text = "Show all Entries" android:layout_width = "fill_parent" /> </TableRow> <TableRow> <Button android:id = "@+id/btnDelete" android:text = "Delete all Entries" android:layout_width = "fill_parent" /> </TableRow> </TableLayout>

    Read the article

  • Can we solve the table row background image problem, in chrome, in multi celled tables??

    - by Ya'el
    It is frequently asked – but I haven’t seen a good answer yet (and I looked). If you set a background image in CSS to a table row- the image will repeat itself in every cell. If you set the position: relative (for the row) and set the background-image: none (for the cells) it solves the problem on IE but not on chrome! I can't use background positioning since there are many calls and their size varies. (And the picture is not symmetrical- It's a fade out from one side. Anybody?? Example for the css code : tr { height: 30px; position:relative;} tr.green {background: url('green_30.png') no-repeat left top;} tr.orange {background: url('oranger_30.png') no-repeat left top;} tr.red {background: url('red_30.png') no-repeat left top;} td {background-image:none;} The HTML is basic - A multi cell table. The goal is to have different colors fade into every row, but it could be any non-pattern image.

    Read the article

  • table row long press

    - by adoo42
    I have a table which is built dynamically based on how much data is present, if at all. I want to be able to long press anywhere on a the table row to be able to get some options to delete or edit etc. Is this possible? Remember I need to do all this without setting any XML as its dynamically built. Is this relevant to what I want to achieve? ` @override public boolean onKeyLongPress(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // do your stuff here return true; } return super.onKeyLongPress(keyCode, event); } ` any advice is appreciated.

    Read the article

  • css displaying divs inside a Tr fine in FireFox, but IE increases the width of the row...

    - by Ronedog
    I'm having some difficulty figuring out what is going on and how to fix it. I have some divs that contain some icons that are causing a width problem when displaying tabular data. If I remove the div's that contain the icons, the row width ends up the way I want it (See the firefox example below). Here's the view in Firefox which is what I want (notice the positioning of the icons circled in red, which is aligned on the same y coordinate, or thereabouts): Here's the view in IE7 (Notice what happens to the icons and the width of the grey line, which is the table row): Here's the HTML: <table> <tbody> <tr> <td> <span>stuff 1</span> <span>stuff 2</span> <div class="prop_edit"><img class="img_height14" src="edit.jpg"></div> <div class="prop_archive"><img class="img_height14" src="archive.jpg"></div> <div class="prop_delete"><img class="img_height14" src="delete.jpg"></div> <div style="display:none;"> <div>Links Here</div> </div> </td> </tr> </tbody> Heres the CSS: .prop_edit{ float:right; position: relative; top: 0px; right:50px; } .prop_archive{ float:right; position: relative; top: 0px; right:10px; } .prop_delete{ float:right; position: relative; top: 0px; right: -30px; } .img_height14{ height:14px; vertical-align:top; position:relative; } I've tried a bunch of different css things, but really am just hacking away hoping to figure something out. Anyone got some tips that could help me? Thanks in advance.

    Read the article

  • Android RatingBar weirdness: Whenever I add a RatingBar to my layout, a bunch of the generated tags,

    - by Rben
    Whenever I use a RatingBar view in my layout, I suddenly get all kinds of compile errors. I'm using Android 2.0, but I've also tried 2.0.1, and 2.1, without joy. I also get a message: Shader 'android.graphics.BitmapShader' is not supported in Layout Editor, and an odd warning which may or maynot be related: warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. I've tried using the RatingBar both within a tablelayout and outside it, but it behaves the same way. This is very puzzling and frustrating. Please help if you can. Sincerely, Ray Here's the XML: <!-- Created By --> <TableRow android:layout_height="wrap_content" android:layout_width="fill_parent" > <TextView android:text="Created by: " android:id="@+id/gi_created_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" /> <TextView android:text="Slartibartfast" android:id="@+id/gi_created" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </TableRow> <!-- Verification --> <TableRow android:layout_height="wrap_content" android:layout_width="fill_parent" > <TextView android:id="@+id/gi_verification_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/GameInfoVerificationLabelText" /> <TextView android:id="@+id/gi_verification" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="HonorSystem" /> </TableRow> <!-- Player Rating Label --> <TableRow android:layout_height="wrap_content" android:layout_width="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:text="@string/GameInfoPlayerRatingLabel" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text=" " /> </TableRow> -- <!-- Times played --> <TableRow android:layout_height="wrap_content" android:layout_width="fill_parent" > <TextView android:id="@+id/gi_times_played_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/GameInfoTimesPlayedLabel" /> <TextView android:id="@+id/gi_times_played" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="999" /> </TableRow> <!-- Total Players --> <TableRow android:layout_height="wrap_content" android:layout_width="fill_parent" > <TextView android:id="@+id/gi_total_players_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/GameInfoTotalPlayerCountLabel" /> <TextView android:id="@+id/gi_total_players" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="999" /> </TableRow> <!-- Total Cancelations --> <TableRow android:layout_height="wrap_content" android:layout_width="fill_parent" > <TextView android:id="@+id/gi_total_cancelations_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/GameInfoTotalCancelsLabel" /> <TextView android:id="@+id/gi_total_cancels" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="999" /> </TableRow> <RatingBar android:id="@+/gi_player_rating" style="?android:attr/ratingBarStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_span="2" android:isIndicator="true" android:numStars="5" android:rating="3" android:stepSize="1" android:layout_gravity="center_vertical" /> </TableRow>

    Read the article

  • How to create Custom ListForm WebPart

    - by DipeshBhanani
    Mostly all who works extensively on SharePoint (including meJ) don’t like to use out-of-box list forms (DispForm.aspx, EditForm.aspx, NewForm.aspx) as interface. Actually these OOB list forms bind hands of developers for the customization. It gives headache to developers to add just one post back event, for a dropdown field and to populate other fields in NewForm.aspx or EditForm.aspx. On top of that clients always ask such stuff. So here I am going to give you guys a flight for SharePoint Customization world. In this blog, I will explain, how to create CustomListForm WebPart. In my next blogs, I am going to explain easy deployment of List Forms through features and last, guidance on using SharePoint web controls. 1.       First thing, create a class library project through Visual Studio and inherit the class with WebPart class.     public class CustomListForm : WebPart   2.       Declare the public variables and properties which we are going to use throughout the class. You will get to know these once you see them in use.         #region "Variable Declaration"           Table spTableCntl;         FormToolBar formToolBar;         Literal ltAlertMessage;         Guid SiteId;         Guid ListId;         int ItemId;         string ListName;           #endregion           #region "Properties"           SPControlMode _ControlMode = SPControlMode.New;         [Personalizable(PersonalizationScope.Shared),          WebBrowsable(true),          WebDisplayName("Control Mode"),          WebDescription("Set Control Mode"),          DefaultValue(""),          Category("Miscellaneous")]         public SPControlMode ControlMode         {             get { return _ControlMode; }             set { _ControlMode = value; }         }           #endregion     The property “ControlMode” is used to identify the mode of the List Form. The property is of type SPControlMode which is an enum type with values (Display, Edit, New and Invalid). When we will add this WebPart to DispForm.aspx, EditForm.aspx and NewForm.aspx, we will set the WebPart property “ControlMode” to Display, Edit and New respectively.     3.       Now, we need to override the CreateChildControl method and write code to manually add SharePoint Web Controls related to each list fields as well as ToolBar controls.         protected override void CreateChildControls()         {             base.CreateChildControls();               try             {                 SiteId = SPContext.Current.Site.ID;                 ListId = SPContext.Current.ListId;                 ListName = SPContext.Current.List.Title;                   if (_ControlMode == SPControlMode.Display || _ControlMode == SPControlMode.Edit)                     ItemId = SPContext.Current.ItemId;                   SPSecurity.RunWithElevatedPrivileges(delegate()                 {                     using (SPSite site = new SPSite(SiteId))                     {                         //creating a new SPSite with credentials of System Account                         using (SPWeb web = site.OpenWeb())                         {                               //<Custom Code for creating form controls>                         }                     }                 });             }             catch (Exception ex)             {                 ShowError(ex, "CreateChildControls");             }         }   Here we are assuming that we are developing this WebPart to plug into List Forms. Hence we will get the List Id and List Name from the current context. We can have Item Id only in case of Display and Edit Mode. We are putting our code into “RunWithElevatedPrivileges” to elevate privileges to System Account. Now, let’s get deep down into the main code and expand “//<Custom Code for creating form controls>”. Before initiating any SharePoint control, we need to set context of SharePoint web controls explicitly so that it will be instantiated with elevated System Account user. Following line does the job.     //To create SharePoint controls with new web object and System Account credentials     SPControl.SetContextWeb(Context, web);   First thing, let’s add main table as container for all controls.     //Table to render webpart     Table spTableMain = new Table();     spTableMain.CellPadding = 0;     spTableMain.CellSpacing = 0;     spTableMain.Width = new Unit(100, UnitType.Percentage);     this.Controls.Add(spTableMain);   Now we need to add Top toolbar with Save and Cancel button at top as you see in the below screen shot.       // Add Row and Cell for Top ToolBar     TableRow spRowTopToolBar = new TableRow();     spTableMain.Rows.Add(spRowTopToolBar);     TableCell spCellTopToolBar = new TableCell();     spRowTopToolBar.Cells.Add(spCellTopToolBar);     spCellTopToolBar.Width = new Unit(100, UnitType.Percentage);         ToolBar toolBarTop = (ToolBar)Page.LoadControl("/_controltemplates/ToolBar.ascx");     toolBarTop.CssClass = "ms-formtoolbar";     toolBarTop.ID = "toolBarTbltop";     toolBarTop.RightButtons.SeparatorHtml = "<td class=ms-separator> </td>";       if (_ControlMode != SPControlMode.Display)     {         SaveButton btnSave = new SaveButton();         btnSave.ControlMode = _ControlMode;         btnSave.ListId = ListId;           if (_ControlMode == SPControlMode.New)             btnSave.RenderContext = SPContext.GetContext(web);         else         {             btnSave.RenderContext = SPContext.GetContext(this.Context, ItemId, ListId, web);             btnSave.ItemContext = SPContext.GetContext(this.Context, ItemId, ListId, web);             btnSave.ItemId = ItemId;         }         toolBarTop.RightButtons.Controls.Add(btnSave);     }       GoBackButton goBackButtonTop = new GoBackButton();     toolBarTop.RightButtons.Controls.Add(goBackButtonTop);     goBackButtonTop.ControlMode = SPControlMode.Display;       spCellTopToolBar.Controls.Add(toolBarTop);   Here we have use “SaveButton” and “GoBackButton” which are internal SharePoint web controls for save and cancel functionality. I have set some of the properties of Save Button with if-else condition because we will not have Item Id in case of New Mode. Item Id property is used to identify which SharePoint List Item need to be saved. Now, add Form Toolbar to the page which contains “Attach File”, “Delete Item” etc buttons.       // Add Row and Cell for FormToolBar     TableRow spRowFormToolBar = new TableRow();     spTableMain.Rows.Add(spRowFormToolBar);     TableCell spCellFormToolBar = new TableCell();     spRowFormToolBar.Cells.Add(spCellFormToolBar);     spCellFormToolBar.Width = new Unit(100, UnitType.Percentage);       FormToolBar formToolBar = new FormToolBar();     formToolBar.ID = "formToolBar";     formToolBar.ListId = ListId;     if (_ControlMode == SPControlMode.New)         formToolBar.RenderContext = SPContext.GetContext(web);     else     {         formToolBar.RenderContext = SPContext.GetContext(this.Context, ItemId, ListId, web);         formToolBar.ItemContext = SPContext.GetContext(this.Context, ItemId, ListId, web);         formToolBar.ItemId = ItemId;     }     formToolBar.ControlMode = _ControlMode;     formToolBar.EnableViewState = true;       spCellFormToolBar.Controls.Add(formToolBar);     The ControlMode property will take care of which button to be displayed on the toolbar. E.g. “Attach files”, “Delete Item” in new/edit forms and “New Item”, “Edit Item”, “Delete Item”, “Manage Permissions” etc in display forms. Now add main section which contains form field controls.     //Create Form Field controls and add them in Table "spCellCntl"     CreateFieldControls(web);     //Add public variable "spCellCntl" containing all form controls to the page     spRowCntl.Cells.Add(spCellCntl);     spCellCntl.Width = new Unit(100, UnitType.Percentage);     spCellCntl.Controls.Add(spTableCntl);       //Add a Blank Row with height of 5px to render space between ToolBar table and Control table     TableRow spRowLine1 = new TableRow();     spTableMain.Rows.Add(spRowLine1);     TableCell spCellLine1 = new TableCell();     spRowLine1.Cells.Add(spCellLine1);     spCellLine1.Height = new Unit(5, UnitType.Pixel);     spCellLine1.Controls.Add(new LiteralControl("<IMG SRC='/_layouts/images/blank.gif' width=1 height=1 alt=''>"));       //Add Row and Cell for Form Controls Section     TableRow spRowCntl = new TableRow();     spTableMain.Rows.Add(spRowCntl);     TableCell spCellCntl = new TableCell();       //Create Form Field controls and add them in Table "spCellCntl"     CreateFieldControls(web);     //Add public variable "spCellCntl" containing all form controls to the page     spRowCntl.Cells.Add(spCellCntl);     spCellCntl.Width = new Unit(100, UnitType.Percentage);     spCellCntl.Controls.Add(spTableCntl);       TableRow spRowLine2 = new TableRow();     spTableMain.Rows.Add(spRowLine2);     TableCell spCellLine2 = new TableCell();     spRowLine2.Cells.Add(spCellLine2);     spCellLine2.CssClass = "ms-formline";     spCellLine2.Controls.Add(new LiteralControl("<IMG SRC='/_layouts/images/blank.gif' width=1 height=1 alt=''>"));       // Add Blank row with height of 5 pixel     TableRow spRowLine3 = new TableRow();     spTableMain.Rows.Add(spRowLine3);     TableCell spCellLine3 = new TableCell();     spRowLine3.Cells.Add(spCellLine3);     spCellLine3.Height = new Unit(5, UnitType.Pixel);     spCellLine3.Controls.Add(new LiteralControl("<IMG SRC='/_layouts/images/blank.gif' width=1 height=1 alt=''>"));   You can add bottom toolbar also to get same look and feel as OOB forms. I am not adding here as the blog will be much lengthy. At last, you need to write following lines to allow unsafe updates for Save and Delete button.     // Allow unsafe update on web for save button and delete button     if (this.Page.IsPostBack && this.Page.Request["__EventTarget"] != null         && (this.Page.Request["__EventTarget"].Contains("IOSaveItem")         || this.Page.Request["__EventTarget"].Contains("IODeleteItem")))     {         SPContext.Current.Web.AllowUnsafeUpdates = true;     }   So that’s all. We have finished writing Custom Code for adding field control. But something most important is skipped. In above code, I have called function “CreateFieldControls(web);” to add SharePoint field controls to the page. Let’s see the implementation of the function:     private void CreateFieldControls(SPWeb pWeb)     {         SPList listMain = pWeb.Lists[ListId];         SPFieldCollection fields = listMain.Fields;           //Main Table to render all fields         spTableCntl = new Table();         spTableCntl.BorderWidth = new Unit(0);         spTableCntl.CellPadding = 0;         spTableCntl.CellSpacing = 0;         spTableCntl.Width = new Unit(100, UnitType.Percentage);         spTableCntl.CssClass = "ms-formtable";           SPContext controlContext = SPContext.GetContext(this.Context, ItemId, ListId, pWeb);           foreach (SPField listField in fields)         {             string fieldDisplayName = listField.Title;             string fieldInternalName = listField.InternalName;               //Skip if the field is system field or hidden             if (listField.Hidden || listField.ShowInVersionHistory == false)                 continue;               //Skip if the control mode is display and field is read-only             if (_ControlMode != SPControlMode.Display && listField.ReadOnlyField == true)                 continue;               FieldLabel fieldLabel = new FieldLabel();             fieldLabel.FieldName = listField.InternalName;             fieldLabel.ListId = ListId;               BaseFieldControl fieldControl = listField.FieldRenderingControl;             fieldControl.ListId = ListId;             //Assign unique id using Field Internal Name             fieldControl.ID = string.Format("Field_{0}", fieldInternalName);             fieldControl.EnableViewState = true;               //Assign control mode             fieldLabel.ControlMode = _ControlMode;             fieldControl.ControlMode = _ControlMode;             switch (_ControlMode)             {                 case SPControlMode.New:                     fieldLabel.RenderContext = SPContext.GetContext(pWeb);                     fieldControl.RenderContext = SPContext.GetContext(pWeb);                     break;                 case SPControlMode.Edit:                 case SPControlMode.Display:                     fieldLabel.RenderContext = controlContext;                     fieldLabel.ItemContext = controlContext;                     fieldLabel.ItemId = ItemId;                       fieldControl.RenderContext = controlContext;                     fieldControl.ItemContext = controlContext;                     fieldControl.ItemId = ItemId;                     break;             }               //Add row to display a field row             TableRow spCntlRow = new TableRow();             spTableCntl.Rows.Add(spCntlRow);               //Add the cells for containing field lable and control             TableCell spCellLabel = new TableCell();             spCellLabel.Width = new Unit(30, UnitType.Percentage);             spCellLabel.CssClass = "ms-formlabel";             spCntlRow.Cells.Add(spCellLabel);             TableCell spCellControl = new TableCell();             spCellControl.Width = new Unit(70, UnitType.Percentage);             spCellControl.CssClass = "ms-formbody";             spCntlRow.Cells.Add(spCellControl);               //Add the control to the table cells             spCellLabel.Controls.Add(fieldLabel);             spCellControl.Controls.Add(fieldControl);               //Add description if there is any in case of New and Edit Mode             if (_ControlMode != SPControlMode.Display && listField.Description != string.Empty)             {                 FieldDescription fieldDesc = new FieldDescription();                 fieldDesc.FieldName = fieldInternalName;                 fieldDesc.ListId = ListId;                 spCellControl.Controls.Add(fieldDesc);             }               //Disable Name(Title) in Edit Mode             if (_ControlMode == SPControlMode.Edit && fieldDisplayName == "Name")             {                 TextBox txtTitlefield = (TextBox)fieldControl.Controls[0].FindControl("TextField");                 txtTitlefield.Enabled = false;             }         }         fields = null;     }   First of all, I have declared List object and got list fields in field collection object called “fields”. Then I have added a table for the container of all controls and assign CSS class as "ms-formtable" so that it gives consistent look and feel of SharePoint. Now it’s time to navigate through all fields and add them if required. Here we don’t need to add hidden or system fields. We also don’t want to display read-only fields in new and edit forms. Following lines does this job.             //Skip if the field is system field or hidden             if (listField.Hidden || listField.ShowInVersionHistory == false)                 continue;               //Skip if the control mode is display and field is read-only             if (_ControlMode != SPControlMode.Display && listField.ReadOnlyField == true)                 continue;   Let’s move to the next line of code.             FieldLabel fieldLabel = new FieldLabel();             fieldLabel.FieldName = listField.InternalName;             fieldLabel.ListId = ListId;               BaseFieldControl fieldControl = listField.FieldRenderingControl;             fieldControl.ListId = ListId;             //Assign unique id using Field Internal Name             fieldControl.ID = string.Format("Field_{0}", fieldInternalName);             fieldControl.EnableViewState = true;               //Assign control mode             fieldLabel.ControlMode = _ControlMode;             fieldControl.ControlMode = _ControlMode;   We have used “FieldLabel” control for displaying field title. The advantage of using Field Label is, SharePoint automatically adds red star besides field label to identify it as mandatory field if there is any. Here is most important part to understand. The “BaseFieldControl”. It will render the respective web controls according to type of the field. For example, if it’s single line of text, then Textbox, if it’s look up then it renders dropdown. Additionally, the “ControlMode” property tells compiler that which mode (display/edit/new) controls need to be rendered with. In display mode, it will render label with field value. In edit mode, it will render respective control with item value and in new mode it will render respective control with empty value. Please note that, it’s not always the case when dropdown field will be rendered for Lookup field or Choice field. You need to understand which controls are rendered for which list fields. I am planning to write a separate blog which I hope to publish it very soon. Moreover, we also need to assign list field specific properties like List Id, Field Name etc to identify which SharePoint List field is attached with the control.             switch (_ControlMode)             {                 case SPControlMode.New:                     fieldLabel.RenderContext = SPContext.GetContext(pWeb);                     fieldControl.RenderContext = SPContext.GetContext(pWeb);                     break;                 case SPControlMode.Edit:                 case SPControlMode.Display:                     fieldLabel.RenderContext = controlContext;                     fieldLabel.ItemContext = controlContext;                     fieldLabel.ItemId = ItemId;                       fieldControl.RenderContext = controlContext;                     fieldControl.ItemContext = controlContext;                     fieldControl.ItemId = ItemId;                     break;             }   Here, I have separate code for new mode and Edit/Display mode because we will not have Item Id to assign in New Mode. We also need to set CSS class for cell containing Label and Controls so that those controls get rendered with SharePoint theme.             spCellLabel.CssClass = "ms-formlabel";             spCellControl.CssClass = "ms-formbody";   “FieldDescription” control is used to add field description if there is any.    Now it’s time to add some more customization,               //Disable Name(Title) in Edit Mode             if (_ControlMode == SPControlMode.Edit && fieldDisplayName == "Name")             {                 TextBox txtTitlefield = (TextBox)fieldControl.Controls[0].FindControl("TextField");                 txtTitlefield.Enabled = false;             }   The above code will disable the title field in edit mode. You can add more code here to achieve more customization according to your requirement. Some of the examples are as follow:             //Adding post back event on UserField to auto populate some other dependent field             //in new mode and disable it in edit mode             if (_ControlMode != SPControlMode.Display && fieldDisplayName == "Manager")             {                 if (fieldControl.Controls[0].FindControl("UserField") != null)                 {                     PeopleEditor pplEditor = (PeopleEditor)fieldControl.Controls[0].FindControl("UserField");                     if (_ControlMode == SPControlMode.New)                         pplEditor.AutoPostBack = true;                     else                         pplEditor.Enabled = false;                 }             }               //Add JavaScript Event on Dropdown field. Don't forget to add the JavaScript function on the page.             if (_ControlMode == SPControlMode.Edit && fieldDisplayName == "Designation")             {                 DropDownList ddlCategory = (DropDownList)fieldControl.Controls[0];                 ddlCategory.Attributes.Add("onchange", string.Format("javascript:DropdownChangeEvent('{0}');return false;", ddlCategory.ClientID));             }    Following are the screenshots of my Custom ListForm WebPart. Let’s play a game, check out your OOB List forms of SharePoint, compare with these screens and find out differences.   DispForm.aspx:   EditForm.aspx:   NewForm.aspx:   Enjoy the SharePoint Soup!!! ­­­­­­­­­­­­­­­­­­­­

    Read the article

  • Layout problem: scrollview inside a table, inside a custom dialog

    - by Sean
    I have a layout problem which I can't fix. I've looked through many posts on here, and mine seems to be unique enough to post a question. I've created a custom Dialog which programmatically creates a 3 row table. The top and bottom rows have text, while the middle row contains a ScrollView, which contains a LinearLayout. That LinearLayout then contains some number of views (TextView in this example). Since I'm doing this programmatically, see the XML pseudocode below, and the actual code below that. What I would like to happen, is that when the height of the contained content in the LinearLayout gets too big, the ScrollView does its job, and the header and footer TextView's are always visible. The problem is that when the dialog gets big enough, the ScrollView appears to take over the whole dialog, and my footer TextView disappears off the screen. What can I do to make sure the footer TextView never disappears, but the ScrollView can still function? See the following image links: Footer visible on the left, gone on the right: http://img690.imageshack.us/i/screenshotss.png/ <TableLayout> <TableRow> <TextView> </TableRow> <TableRow> <ScrollView> <LinearLayout> <TextView/> <TextView/> <TextView/> ... </LinearLayout> </ScrollView> </TableRow> <TableRow> <TextView> </TableRow> </TableLayout> Here's the code: public class DialogScrollTest extends Dialog { public DialogScrollTest(Context ctx){ super(ctx); setTitle(""); requestWindowFeature(Window.FEATURE_NO_TITLE); TableLayout table = new TableLayout(ctx); TableRow row; TextView text; row = new TableRow(ctx); { text = new TextView(ctx); text.setText("TestTop"); row.addView(text); } table.addView(row); row = new TableRow(ctx); { ScrollView scroll = new ScrollView(ctx); { LinearLayout linear = new LinearLayout(ctx); linear.setOrientation(LinearLayout.VERTICAL); for(int t=0; t<32; ++t){ text = new TextView(ctx); text.setText("TestScroll"); linear.addView(text); } scroll.addView(linear); } row.addView(scroll); } table.addView(row); row = new TableRow(ctx); { text = new TextView(ctx); text.setText("TestBottom"); row.addView(text); } table.addView(row); this.setContentView(table); } }

    Read the article

  • iPhone:How to set background image for tablerow cell?

    - by user187532
    Hello all, I want to put some background image for TableView row cell. I am using the following code: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ..................... ................... UIImage * backgroundImage = [UIImage imageNamed:@"cell.png"]; UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage:backgroundImage]; cell.opaque = NO; cell.contentView.opaque = NO; cell.backgroundColor = [UIColor clearColor]; cell.backgroundColor = backgroundColor; //cell.contentView.backgroundColor = [UIColor clearColor]; //cell.contentView.backgroundColor = backgroundColor; } But it is not giving the background image properly. Could someone guide me what is the proper ways of setting background image for a tableview row? Note: I'm also setting background image for my TableView as well using the below code: UIImage * backgroundImage = [UIImage imageNamed:@"Tablebackground.png"]; UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage:backgroundImage]; self.myTableView.backgroundColor = [UIColor clearColor]; self.myTableView.alpha = 0.9; self.myTableView.backgroundColor = backgroundColor; I don't observe any problem for tableview background. Only thing here is, tableview background image is not being static, when scrolling happening, image is also scrolling. But i want to know first how to set background image for Tableview row cell? Thank you.

    Read the article

  • How to set padding to columns in table layout dynamically

    - by Praveenb
    Hi all, I am trying to create a table layout with buttons dynamically. I am able to get the table layout with buttons. bt i need padding between buttons. How i can get programatically. I tried following code bt private void showCowsTblField() { for (int row = 0; row < numberOfRowsInField-1; row++) { TableRow tableRow = new TableRow(this); tableRow.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT )); for (int column = 0; column < numberOfColumnsInField -1; column++) { blocks[row][column].setLayoutParams(new LayoutParams( LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); blocks[row][column].setPadding(blockPadding, blockPadding, blockPadding, blockPadding); tableRow.addView(blocks[row][column]); tableRow.setPadding(blockPadding, blockPadding, blockPadding, blockPadding); } tblCows.addView(tableRow,new TableLayout.LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); } } Please let me know.... Thanks.

    Read the article

  • How to get table cells evenly spaced?

    - by DaveDev
    I'm trying to create a page with a number of static html tables on them. What do I need to do to get them to display each column the same size as each other column in the table? The HTML is as follows: <span class="Emphasis">Interest rates</span><br /> <table cellpadding="0px" cellspacing="0px" class="PerformanceTable"> <tr><th class="TableHeader"></th><th class="TableHeader">Current rate as at 31 March 2010</th><th class="TableHeader">31 December 2009</th><th class="TableHeader">31 March 2009</th></tr> <tr class="TableRow"><td>Index1</td><td class="PerformanceCell">1.00%</td><td>1.00%</td><td>1.50%</td></tr> <tr class="TableRow"><td>index2</td><td class="PerformanceCell">0.50%</td><td>0.50%</td><td>0.50%</td></tr> <tr class="TableRow"><td>index3</td><td class="PerformanceCell">0.25%</td><td>0.25%</td><td>0.25%</td></tr> </table> <span>Source: Bt</span><br /><br /> <span class="Emphasis">Stock markets</span><br /> <table cellpadding="0px" cellspacing="0px" class="PerformanceTable"> <tr><th class="TableHeader"></th><th class="TableHeader">As at 31 March 2010</th><th class="TableHeader">1 month change</th><th class="TableHeader">QTD change</th><th class="TableHeader">12 months change</th></tr> <tr class="TableRow"><td>index1</td><td class="PerformanceCell">1169.43</td><td class="PerformanceCell">5.88%</td><td class="PerformanceCell">4.87%</td><td class="PerformanceCell">46.57%</td></tr> <tr class="TableRow"><td>index2</td><td class="PerformanceCell">1958.34</td><td class="PerformanceCell">7.68%</td><td class="PerformanceCell">5.27%</td><td class="PerformanceCell">58.31%</td></tr> <tr class="TableRow"><td>index3</td><td class="PerformanceCell">5679.64</td><td class="PerformanceCell">6.07%</td><td class="PerformanceCell">4.93%</td><td class="PerformanceCell">44.66%</td></tr> <tr class="TableRow"><td>index4</td><td class="PerformanceCell">2943.92</td><td class="PerformanceCell">8.30%</td><td class="PerformanceCell">-0.98%</td><td class="PerformanceCell">44.52%</td></tr> <tr class="TableRow"><td>index5</td><td class="PerformanceCell">978.81</td><td class="PerformanceCell">9.47%</td><td class="PerformanceCell">7.85%</td><td class="PerformanceCell">26.52%</td></tr> <tr class="TableRow"><td>index6</td><td class="PerformanceCell">3177.77</td><td class="PerformanceCell">10.58%</td><td class="PerformanceCell">6.82%</td><td class="PerformanceCell">44.84%</td></tr> </table> <span>Source: B</span><br /><br /> I'm also open to suggestion on how to tidy this up, if there are any? :-)

    Read the article

  • Ellipsize not working for textView inside custom listView

    - by aspartame
    Hi, I have a listView with custom objects defined by the xml-layout below. I want the textView with id "info" to be ellipsized on a single line, and I've tried using the attributes android:singleLine="true" android:ellipsize="end" without success. If I set the layout_width to a fixed width like e.g. android:layout_width="100px" the text is truncated fine. But for portability reasons this is not an acceptable solution. Can you spot the problem? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingBottom="5px" > <TextView android:id="@+id/destination" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="22dp" android:paddingLeft="5px" /> <TextView android:id="@+id/date" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="15dp" android:paddingLeft="5px" /> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/info_table" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="5px" android:paddingTop="10px" > <TableRow> <TextView android:id="@+id/driver_label" android:gravity="right" android:paddingRight="5px" android:text="@string/driver_label" /> <TextView android:id="@+id/driver" /> </TableRow> <TableRow> <TextView android:id="@+id/passenger_label" android:gravity="right" android:paddingRight="5px" android:text="@string/passenger_label" /> <TextView android:id="@+id/passengers" /> </TableRow> <TableRow> <TextView android:id="@+id/info_label" android:gravity="right" android:paddingRight="5px" android:text="@string/info_label"/> <TextView android:id="@+id/info" android:layout_width="fill_parent" android:singleLine="true" android:ellipsize="end" /> </TableRow> </TableLayout>

    Read the article

  • How can I get an Android TableLayout to fill the screen?

    - by Timmmm
    Hi, I'm battling with Android's retarded layout system. I'm trying to get a table to fill the screen (simple right?) but it's ridiculously hard. I got it to work somehow in XML like this: <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1"> <Button android:text="A" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <Button android:text="B" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> </TableRow> <TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1"> <Button android:text="C" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <Button android:text="D" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> </TableRow> However I can not get it to work in Java. I've tried a million combinations of the LayoutParams, but nothing ever works. This is the best result I have which only fills the width of the screen, not the height: table = new TableLayout(this); // Java. You suck. TableLayout.LayoutParams lp = new TableLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); table.setLayoutParams(lp); // This line has no effect! WHYYYY?! table.setStretchAllColumns(true); for (int r = 0; r < 2; ++r) { TableRow row = new TableRow(this); for (int c = 0; c < 2; ++c) { Button btn = new Button(this); btn.setText("A"); row.addView(btn); } table.addView(row); } Obviously the Android documentation is no help. Anyone have any ideas?

    Read the article

  • Unable to stretch TableLayout to screen width

    - by Rendrik
    I've tried unsuccessfully for quite a few hours now to simply get a TableLayout to scale to the full screen. I've tried stretchColumns, shrinkColumns, (specifying the column index or using *) you name it. It's almost as if the parent element (TableLayout) is completely ignoring 'android:layout_width="fill_parent"'. I've read through similar questions here, though they haven't solved it for me. The XML below has 3 rows, and the table always shrink wraps to the size of the content. Apparently I'm too new to post pictures(?) Here is the XML rendered into the project i'm working on. http://www.dashiva.com/images/Capture.png What am I missing here, it's quite frustrating! <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="*"> <TableRow> <TextView android:id="@+id/AmountText" android:text="@string/general_amount" android:paddingRight="8dip" android:layout_gravity="center"></TextView> <TextView android:id="@+id/CardText" android:text="@string/general_card" android:paddingRight="8dip" android:layout_gravity="center"></TextView> <TextView android:text="@string/general_date" android:id="@+id/DateText" android:paddingRight="8dip" android:layout_gravity="center"></TextView> <TextView android:id="@+id/ErrorText" android:text="@string/general_error" android:paddingRight="8dip" android:layout_gravity="center"></TextView> </TableRow> <TableRow> <TextView android:text="Amount here..." android:id="@+id/AmountNum" android:paddingRight="8dip" android:layout_gravity="center"></TextView> <TextView android:id="@+id/CardNum" android:text="Num here..." android:paddingRight="8dip" android:layout_gravity="center"></TextView> <TextView android:text="date here..." android:id="@+id/DateDate" android:paddingRight="8dip" android:layout_gravity="center"></TextView> <TextView android:text="Code here..." android:id="@+id/ErrorCode" android:paddingRight="8dip" android:layout_gravity="center"></TextView> </TableRow> <TableRow> <ImageView android:id="@+id/cc_image" android:src="@drawable/mastercard" android:background="@drawable/row_bg2" android:layout_gravity="center" android:layout_weight="1"></ImageView> <TextView android:id="@+id/ResponseText" android:layout_span="4" android:text="Response text here..." android:textSize="18dip" android:layout_weight="1"></TextView> </TableRow> <ImageView android:layout_gravity="center_vertical" android:background="@drawable/gradient_bg" android:layout_height="3dip" android:layout_width="fill_parent"></ImageView> </TableLayout>

    Read the article

  • android spinner width problem?

    - by UMMA
    dear friends, i have created following layout. <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TableRow> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Post As" /> <Spinner android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/ddlPostAs" /> </TableRow> <TableRow> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Expires In" /> <Spinner android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/ddlExpiryOn" /> </TableRow> </TableLayout> in which android spinner changes its width according to the data. i want to stop it. can any one guide me how to achieve this? any help would be appriciated.

    Read the article

  • LayoutInflater ignoring parameters ?

    - by TiGer
    Hi, I have the following xml object representing a ImageButton <?xml version="1.0" encoding="utf-8"?> <ImageButton xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/genreCellItemId" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:paddingLeft="5.0dip" android:paddingRight="5.0dip"> </ImageButton> I try to inflate it and add it to a TableRow with the following code : LayoutInflater inflater= this.getLayoutInflater(); TableLayout grid = (TableLayout)findViewById(R.id.bodyTableLayout); TableRow row = (TableRow)inflater.inflate(R.layout.genre_row, null); View myButton = (View)inflater.inflate(R.layout.genre_cell, null); row.addView(tempButton, new TableRow.LayoutParams()); grid.addView(row, new TableLayout.LayoutParams()); Ok so I noticed that it didn't look as expected, so I fire up the Hierarchy Viewere and noticed that the ImageButton's actually have an layout_width = FILL_PARENT instead of WRAP_CONTENT, also the layout_gravity is NONE and there is no padding to be seen... Do, am I inflating it wrongly ? Or is maybe the new TableRow.LayoutParams() part doins omething wrong ?

    Read the article

  • How Do I make my own keyboard for an app in android

    - by Ephraim
    I am currently working on an app, that requires a keyboard in a different language (Specifically Hebrew), the problem is, that I don't know where to begin. I don't want the user to have to go onto an app store, and install a separate app that has more languages in it just to use my app, and, I only want the keyboard to be available in my app, ie, it shouldn't effect anything outside my specific app. the way I am doing it right now, is to create it as part of the main layout, and just make it visible whenever the user clicks on the Edit Text. the problem with this, is I can't get the size of it to readjust. I had originally tried using 2 different layouts (one in the res/layout folder, and one in the res/layout-lnd folder), but this caused different problems in my app, making it slower. so I am wondering 2 things, either of which should work. one: how would I create the layout for the keyboard to readjust. or Two: how would I make a keyboard correctly. here is the xml code that I am useing specifically partaining to the keyboard: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:visibility="gone" android:background="@color/puzzle_dark" android:id="@+id/hebrwKeyboardView" android:layout_width="fill_parent" android:layout_height="146dip" android:layout_gravity="right|center_vertical|center_horizontal|bottom" android:fitsSystemWindows="true" android:clipChildren="false" android:orientation="vertical" > <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="145dip" android:clipChildren="false" android:layout_gravity="center_vertical|center_horizontal|bottom" android:fitsSystemWindows="true" android:orientation="horizontal" > <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="145dip" android:clipChildren="false" android:layout_gravity="center_vertical|center_horizontal|bottom" android:fitsSystemWindows="true" android:orientation="vertical" > <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center_vertical|center" android:fitsSystemWindows="true" android:clipChildren="false" android:orientation="horizontal" android:stretchColumns="true"> <LinearLayout android:baselineAligned="true" android:layout_width="fill_parent" android:layout_gravity="center" android:layout_height="fill_parent" android:fitsSystemWindows="true" android:clipChildren="false" android:orientation="horizontal"> <Button android:id="@+id/KoofButton" android:layout_width="wrap_content" android:layout_height="35dip" android:text="@string/Koof" android:layout_gravity="center" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/raishButton" android:layout_width="wrap_content" android:layout_height="35dip" android:text="@string/Raish" android:layout_gravity="center_horizontal" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/alephButton" android:layout_gravity="center_horizontal" android:layout_width="wrap_content" android:layout_height="35dip" android:text="@string/Alef" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/tetButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:layout_height="35dip" android:text="@string/Tet" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/vuvButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal" android:text="@string/Vuv" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/nunSophitButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal" android:text="@string/NunSofit" android:fitsSystemWindows="true" android:gravity="fill" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/memSofitButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:layout_height="35dip" android:text="@string/MemSofit" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/payButton" android:layout_width="wrap_content" android:layout_height="35dip" android:text="@string/Pay" android:fitsSystemWindows="true" android:layout_gravity="center_horizontal" android:ellipsize="marquee"/> </LinearLayout> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:clipChildren="true" android:layout_gravity="center_horizontal|center_vertical|center" android:fitsSystemWindows="true" android:orientation="horizontal"> <RelativeLayout android:layout_width="fill_parent" android:clipChildren="true" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center" android:gravity="bottom" android:orientation="horizontal"> <Button android:layout_alignWithParentIfMissing="true" android:soundEffectsEnabled="true" android:id="@+id/shinButton" android:layout_width="wrap_content" android:layout_centerHorizontal="true" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Shin" android:layout_alignParentLeft="true" android:fitsSystemWindows="true" /> <Button android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:layout_toRightOf="@id/shinButton" android:id="@+id/dalidButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Dalid" android:layout_alignWithParentIfMissing="true" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/gimleButton" android:layout_toRightOf="@id/dalidButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Gimle" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/chufButton" android:layout_toRightOf="@id/gimleButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Chuf" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/ieyinButton" android:layout_toRightOf="@id/chufButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Ieyin" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/yudButton" android:layout_toRightOf="@id/ieyinButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Yud" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/chetButton" android:layout_toRightOf="@id/yudButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Chet" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/lamidButton" android:layout_toRightOf="@id/chetButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Lamid" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/chufSofitButton" android:layout_toRightOf="@id/lamidButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/ChufSofit" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/paySofitButton" android:layout_toRightOf="@id/chufSofitButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/PaySofit" android:fitsSystemWindows="true" /> </RelativeLayout> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center_vertical|center" android:fitsSystemWindows="true" android:orientation="horizontal"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center" android:gravity="bottom" android:orientation="horizontal"> <Button android:soundEffectsEnabled="true" android:id="@+id/zionButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Zion" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/samichButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Samich" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/betButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Bet" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/heyButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Hey" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/nunButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Nun" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/memButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Mem" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/tzadiButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Tzadi" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/tuffButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Tuff" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/tzadiSofitButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/TzadiSofit" android:fitsSystemWindows="true" /> </LinearLayout> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center_vertical|center" android:fitsSystemWindows="true" android:orientation="horizontal"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center" android:gravity="bottom" android:orientation="horizontal"> <Button android:soundEffectsEnabled="true" android:id="@+id/hebrewBackButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="right" android:fitsSystemWindows="true" android:text="&lt;--"/> <Button android:soundEffectsEnabled="true" android:id="@+id/hebrewSpaceButton" android:layout_width="150dip" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/hebrewDoneButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:text="Done" android:fitsSystemWindows="true" /> </LinearLayout> </TableRow> </TableLayout> </TableLayout> </FrameLayout> Here is a picture of what it looks like right now in portrait: and here is what it looks like in landscape:

    Read the article

1 2 3 4 5  | Next Page >