0
请帮助我如何以编程方式实现此类功能。如何在textview-listview-textview之后放置textview-listview-textview android
的TextView
的ListView
的TextView
的TextView
的ListView
的TextView
这里是layout.xml
<LinearLayout
android:id="@+id/layoutlist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/gsy"
android:orientation="vertical" >
<TextView
android:id="@+id/rsegtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RateSegmentname"/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="10dp" >
</ListView>
<TextView
android:id="@+id/total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total"/>
</LinearLayout>
下面是代码,其中i可以添加细节到listview
for(a = 1; a < ratesegcode; a++){
ArrayList<ClassForComputation> listcomputation = new ArrayList<ClassForComputation>();
double sum = 0;
double gamount = 0;
String query = "SELECT rcomponent, amnt, gamount FROM computation WHERE ratesegmentcode =\""+a+"\" ORDER BY ratesegmentcode, printorder";
Cursor c = db.rawQuery(query, null);
if(c != null && c.getCount() != 0){
c.moveToFirst();
do{
TextView rsegtitle = (TextView)findViewById(R.id.rsegtitle);
rsegtitle.setText(GetRateSegment(a));
ClassForComputation clsfrcomp = new ClassForComputation();
clsfrcomp.setratecomponent(c.getString(c.getColumnIndex("rcomponent")));
clsfrcomp.setamount(c.getDouble(c.getColumnIndex("amnt")));
gamount = c.getDouble(c.getColumnIndex("gamount"));
clsfrcomp.setgrossamount(gamount);
sum = sum + gamount;
listcomputation.add(clsfrcomp);
}while(c.moveToNext());
PowerUtilityAdapter powerListAdapter = new PowerUtilityAdapter(this, listcomputation);
lv.setAdapter(powerListAdapter);
}
TextView total = (TextView)findViewById(R.id.total);
String totl = Double.toString(sum);
total.setText(totl);
c.close();
}
谢谢你们!