Aks*_*hay 5 user-interface android
嗨,我已经像下面的屏幕一样开发了UI.现在我想在最后一个加按钮点击事件的UI中添加最后一行.
我知道如何添加Button或EditText动态,但我没有得到如何添加和删除具有多列动态的行.
编辑: -关于最后一行的一个重要的事情是每列都是可编辑的.这意味着我需要每列的引用来获取它的内容.当我动态添加行时加上按钮应该放在新行中.同样如果我删除行加号按钮应该转移到上一行.
我怎么能这样做.任何指南或任何方法将不胜感激.
这是我的XML文件.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/navi_bar" />
<Button
android:id="@+id/title_bar_btnBack"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:background="@drawable/back_button_image" />
<Button
android:id="@+id/title_bar_btnExport"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/title_bar_btnBack"
android:layout_marginRight="10dp"
android:background="@drawable/export_button_normal" />
<!-- Create PDF Part 2 -->
<ImageView
android:id="@+id/pdf_Upper_Image"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/title_bar_btnBack"
android:background="@drawable/grid_bg_part1" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/pdf_Upper_Image"
android:layout_alignParentLeft="true"
android:text="Kassenbuch"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#3EC7F9"
android:textSize="23dp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="@+id/textView1"
android:text="Name :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="@+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView2"
android:layout_alignTop="@+id/textView2"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/textView2"
android:text="Akshay"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<!-- Custom Pdf Part 2 -->
<ImageView
android:id="@+id/pdf_Middle_Image"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/pdf_Upper_Image"
android:background="@drawable/grid_bg_part2"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/pdf_Middle_Image"
android:layout_marginLeft="2dp"
android:text="Einnahmen"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/txtName"
android:layout_alignTop="@+id/txtName"
android:layout_marginLeft="82dp"
android:layout_toRightOf="@+id/txtName"
android:text="Month :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_alignLeft="@+id/textView4"
android:layout_marginBottom="2dp"
android:text="Mand Nr. :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="@+id/txtMand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView5"
android:layout_alignTop="@+id/textView5"
android:layout_toRightOf="@+id/textView5"
android:text="Mand"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="@+id/txtMonth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/txtName"
android:layout_alignTop="@+id/textView4"
android:layout_toRightOf="@+id/textView5"
android:text="05"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp"
/>
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/txtYear"
android:layout_alignTop="@+id/txtMonth"
android:layout_toLeftOf="@+id/title_bar_btnExport"
android:text="Year :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView5"
android:layout_alignBottom="@+id/textView5"
android:layout_alignLeft="@+id/textView8"
android:text="Blatt :"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="@+id/txtYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/txtMonth"
android:layout_alignLeft="@+id/title_bar_btnExport"
android:layout_alignTop="@+id/txtMonth"
android:text="2012"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/pdf_Middle_Image"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/textView3"
android:text="Ausgabne"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9" >
</TextView>
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/pdf_Middle_Image"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/textView6"
android:text="Bestand"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9" />
<TextView
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/pdf_Middle_Image"
android:layout_toLeftOf="@+id/txtMand"
android:text="Datum"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9" />
<TextView
android:id="@+id/textView13"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/pdf_Middle_Image"
android:layout_toLeftOf="@+id/textView5"
android:text="Beleg Konto"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="8dp" />
<TextView
android:id="@+id/textView14"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView13"
android:layout_alignTop="@+id/pdf_Middle_Image"
android:layout_marginRight="03dp"
android:layout_toLeftOf="@+id/textView13"
android:text="Gegen Konto"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="08dp" />
<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_alignRight="@+id/textView1"
android:layout_below="@+id/textView14"
android:text="Anfangsbestand/Ubertrag"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="9dp" />
<TextView
android:id="@+id/textView11"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView13"
android:layout_alignTop="@+id/pdf_Middle_Image"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@+id/textView12"
android:text="USt satz."
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="09dp" />
<TextView
android:id="@+id/txtBlatt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView9"
android:layout_alignBottom="@+id/textView9"
android:layout_toRightOf="@+id/textView9"
android:text="Blatt"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9"
android:textSize="12dp" />
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView11"
android:layout_alignLeft="@+id/textView9"
android:text="Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#3EC7F9" />
<include android:id="@+id/firstRow"
layout="@layout/custom_pdf3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/pdf_Middle_Image"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
谢谢
在尝试了很多不同的事情之后,我解决了我的问题,如下所示。我在 xml 中进行了某些更改。我使用LinearLayout了ScrollView.
我创建了一个具有完整行的 xml 文件。现在我的任务是按LinearLayout以下方式添加该 xml。我每次都在按钮单击事件上调用此方法。
public void AddDynamicView() {
linearLayout = (LinearLayout) findViewById(R.id.show_pdfTableLayout);
layoutInflater = (LayoutInflater) getApplicationContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.custom_pdf3, null);
linearLayout.addView(view);
list.add(view); // Here I have created list of View so that I can get the id of specific view.
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过这个,TableLayout但我在占用整行时遇到了一些问题。这就是我使用的原因LinearLayout。
| 归档时间: |
|
| 查看次数: |
2726 次 |
| 最近记录: |