标签: tablelayout

android:tablerow与列和多行文本混合

我想让tablelayout包含几个tablerows.其中一行包含4个按钮,而第二行包含非常长的文本.但是,按钮的宽度会随着第二行中的文本而延伸.反正有没有阻止这个?

alt text http://i40.tinypic.com/34srli0.jpg alt text http://i44.tinypic.com/2505dmf.jpg

http://img684.imageshack.us/i/tableview1.jpg/

http://img521.imageshack.us/i/tableview2.jpg/

这是我的xml文件:(不知何故,这个网站对xml文件不友好)

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>

Button
android:id="@+id/widget31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
>
</Button>

Button
android:id="@+id/widget32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
>
</Button>

Button
android:id="@+id/widget33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
>
</Button>
</TableRow>

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"
>
</TextView>
</TableRow>

</TableLayout>
</AbsoluteLayout>
Run Code Online (Sandbox Code Playgroud)

android view tablelayout tablerow

5
推荐指数
1
解决办法
2858
查看次数

Android中的水平和垂直滚动条与tablelayout?

如果您知道如何添加两个滚动条,请帮助我.
首先,我清楚所有人.
我在tablelayout中添加了两个滚动条,但主要问题是使用动态数据来填充tablerow.因此,如果只有一个记录,那么水平滚动视图顶部在数据之后.但我想在底部显示水平,也显示垂直.


谢谢
Prashant

java android tablelayout

5
推荐指数
1
解决办法
1万
查看次数

尝试打开Android XML视图时,在Eclipse中抛出NullPointerException?

这是一个例外:

java.lang.NullPointerException
at android.widget.TextView.setTextColor(TextView.java:1787)
at android.widget.TabHost$LabelIndicatorStrategy.createIndicatorView(TabHost.java:521)
at android.widget.TabHost.addTab(TabHost.java:204)
at com.android.layoutlib.bridge.Bridge.setupTabHost(Bridge.java:880)
at com.android.layoutlib.bridge.Bridge.postInflateProcess(Bridge.java:807)
at com.android.layoutlib.bridge.Bridge.postInflateProcess(Bridge.java:813)
at com.android.layoutlib.bridge.Bridge.computeLayout(Bridge.java:401)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.computeLayout(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.pageChange(Unknown Source)
at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1061)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2743)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1429)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3540)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3161)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at …
Run Code Online (Sandbox Code Playgroud)

xml eclipse android include tablelayout

5
推荐指数
2
解决办法
4643
查看次数

TableRow span不适用于动态添加的行

我有以下问题跨越动态添加行到滚动视图内的TableLayout.行遵循以下模式:

第1行:整个表格上的单元格
第2行:两个单元格
第3行:整个表格上的单元格
...
行N:两个单元格

问题是跨越行的一个单元格的行实际上根本不跨越.它到达屏幕中间的某个点,只是在高处包裹.

以下是Android 2.3.3下的问题的屏幕截图: 跨度布局问题

请注意,下面的示例过于简单(但仍然跨越不起作用).他们准备尝试 - 只需创建文件.我调试了,似乎布局参数在某种程度上消失了.此外,如果TableLayout在main.xml文件中是硬编码的,那么没有问题.不幸的是,我需要动态生成视图.

TestProject.java

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

public class TestProject extends Activity {
        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                TableLayout table = new TableLayout(this);
                ScrollView contentHolder = (ScrollView) findViewById(R.id.scrollView1);
                contentHolder.addView(table, new TableLayout.LayoutParams(
                        TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
                TableRow row1 = (TableRow) View.inflate(this, R.layout.table_span_row, null);
                TableRow.LayoutParams rowSpanLayout = new TableRow.LayoutParams(
                        TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
                rowSpanLayout.span = 2;
                table.addView(row1, rowSpanLayout);
                TableRow row2 …
Run Code Online (Sandbox Code Playgroud)

android tablelayout tablerow

5
推荐指数
1
解决办法
8845
查看次数

动态添加的表行未显示

我看过很多关于动态添加表行的帖子,但我不确定我缺少什么.

当我执行以下操作时,不显示任何内容(除了应用程序标题栏).

我的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        android:id="@+id/table_view_test_main"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        xmlns:android="http://schemas.android.com/apk/res/android"
        >
    <ScrollView
            android:id="@+id/tvt_scroll"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            >
        <RelativeLayout
                android:id="@+id/tvt_scroll_relative"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
            <TableLayout
                    android:id="@+id/tvt_tableview"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    >
            </TableLayout>
        </RelativeLayout>
    </ScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我的活动:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.table_view);

    TableLayout tableLayout = (TableLayout) findViewById(R.id.tvt_tableview);

    TableRow tableRow = new TableRow(this);
    tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));

    TextView column1 = new TextView(this);
    column1.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    column1.setBackgroundColor(Color.YELLOW);
    column1.setTextColor(Color.BLUE);
    column1.setText("Col1 Value");
    tableRow.addView(column1);

    TextView column2 = new TextView(this);
    column2.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    column2.setBackgroundColor(Color.RED);
    column2.setTextColor(Color.GREEN);
    column2.setText("Col2 Value");
    tableRow.addView(column2);

    tableLayout.addView(tableRow, …
Run Code Online (Sandbox Code Playgroud)

java android tablelayout tablerow

5
推荐指数
1
解决办法
3138
查看次数

如何获取最后一个滚动视图位置,scrollview

我正在使用TableLayout.有100个项目可以滚动我在ScrollView中使用Tablelayout.但我必须检测用户是否已滚动到最后一行.如果用户已滚动到最后一个视图,则将向用户显示Toast消息.但是如何知道用户已滚动到tablelayout的最后一行.我已经在ScrollVie w中引用了TableLayout中的代码.

http://huuah.com/using-tablelayout-on-android/

android scrollview tablelayout

5
推荐指数
1
解决办法
1万
查看次数

动态tablelayout创建的android应用程序崩溃

似乎我不是第一个动态创建TableLayOut的人.问题是,当我将TableRow对象添加到TableLayout时,我的android应用程序崩溃并完成了意外错误.

我想做的事?我想用下一个项目布局创建对话框

-------------------
|Custom |____|____| <-- Something like property grid
|graphic|____|____|
|view   |____|____|
|       |____|____|
-------------------
Run Code Online (Sandbox Code Playgroud)

关闭按钮

为了做到这一点,我正在使用下一个方法.

1.创建DialogLayout类
2.创建Dialog类

public class DialogLayout extends LinearLayout
{
   private CustomView m_view;
   private TableLayout m_layout;
   private TableRow m_row0;
   private TextView m_propName;
   private EditText m_propValue;

   public DialogLayout(Context context)
   {
        super(context);
        Init(context);
   }

   private void Init(Context context)
   {
      setOrientation(LinearLayout.HORIZONTAL);

      m_layout = new TableLayout(context);
      m_layout.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      m_layout.setStretchAllColumns(true);

      m_propName= new TextView(context);
      m_propName.setText("PropName:");

      m_propValue = new EditText(context);
      m_propValue.setText("--");

      m_row0 = new TableRow(context);
      m_row0.addView(m_propName);
      m_row0.addView(m_propValue);      
      m_layout.addView(m_row0, …
Run Code Online (Sandbox Code Playgroud)

android tablelayout

5
推荐指数
1
解决办法
2305
查看次数

在android中具有表格布局的可扩展列表视图

我必须创建一个包含3个可扩展列表视图的布局,并且每个expandableview都包含一个表格布局,在展开时显示.

在此输入图像描述

有没有任何工作或任何建议.

android expandable tablelayout

5
推荐指数
0
解决办法
2174
查看次数

超慢的tablelayout性能

我遇到了可怕的TableLayout性能.我在这里读了一些关于同样的帖子......

Android动态创建表 - 性能不佳

我在已经很复杂的布局中使用了tablelayout.我已经使用了很多视图,当然我使用的视图越多,性能越差,这是显而易见的,但我想知道与其他小部件相比,性能是如何可能的那么糟糕.

在我的例子中,一个表格布局,假设5*5文本视图(行中只有纯文本视图)导致系统冻结的时间超过1.5秒,有时只是通过更新TextView.我不是在谈论渲染整个表,而只是在tablelayout中更新一个textview.

我怀疑是setColumnsStretchable(),但即使将其设置为永不拉伸,性能也是一样的.

public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    final TextView target=(TextView)seekBar.getTag();
    target.setText(""+progress);
}
Run Code Online (Sandbox Code Playgroud)

这是我用来更新单元格的代码.如您所见,它是SeekBar监听器的一部分.我甚至不需要findView()或任何东西,因为我将目标textview存储为seekbar的标签.

因此,移动搜索栏会导致跳跃:需要超过一秒钟!单独执行setText().如果我更新不在表内的任何其他文本视图,则会立即按预期更新.

如果我的桌子是10*10,那么它需要3秒钟!

在你的经历TableLayout是否禁止或者我可能做错了什么?也许行或单元布局的一些神奇值?

提前致谢.

performance android tablelayout

5
推荐指数
0
解决办法
1466
查看次数

如何在Android中的tableLayout中动态添加行

我有一个函数从网页获取产品列表,我想在tableLayout中为列表的每个元素添加一行.

public void getProductsOfCategory() throws IOException{
        new Thread(){
            public void run(){
                //background code...
                try {
                    Bundle extras = getIntent().getExtras();
                    String categoryName = extras.getString("categoryName");

                    HttpGet httpget = new HttpGet("http://romal.hopto.org/foodadvisor/users/getProductsOfCategory.json?category="+categoryName);
                    HttpResponse httpresp = httpClient.execute(httpget);
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    httpresp.getEntity().writeTo(baos);
                    final String content = new String(baos.toByteArray());
                    CategoryActivity.this.runOnUiThread(new Runnable(){
                        public void run(){
                            //foreground code (UI)
                            //update user interface, for example, showing messages
                            try {
                                JSONObject jObject = new JSONObject(content);
                                JSONArray productsList = jObject.getJSONArray("response");
                                for(int i=0; i<productsList.length();i++){
                                    JSONObject product = productsList.getJSONObject(i);
                                    JSONObject productData = …
Run Code Online (Sandbox Code Playgroud)

android row add dynamic tablelayout

5
推荐指数
1
解决办法
3万
查看次数

标签 统计

android ×10

tablelayout ×10

tablerow ×3

java ×2

add ×1

dynamic ×1

eclipse ×1

expandable ×1

include ×1

performance ×1

row ×1

scrollview ×1

view ×1

xml ×1