編輯:初級開發
解決方法:
代碼
package com.android;
import Java.util.ArrayList;
import Java.util.HashMap;
import Java.util.List;
import Java.util.Map;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.VIEw;
import android.view.VIEwGroup;
import android.widget.HorizontalScrollVIEw;
import android.widget.ImageVIEw;
import android.widget.LinearLayout;
import android.widget.ListVIEw;
import android.widget.SimpleAdapter;
import android.widget.TextVIEw;
public class TableList extends Activity {
private ListVIEw lv;
/** Called when the activity is first created. */
String name[]={"周旋","於世龍","於翠","楊濤","覃達","周旋","於世龍","於翠","楊濤","覃達"};
String course[]={"語文","數學","英語","歷史","政治","語文","數學","英語","歷史","政治"};
String score[]={"100","90","30","50","90","100","90","30","50","90"};
String id[]={"10123","10124","10125","10126","10127","10123","10124","10125","10126","10127"};
String py[]={"良好","良好","一般","良好","良好","良好","很好","差","一般","不好"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ArrayList> mylist = new ArrayList>();
for (int i = 0; i < name.length; i++) {
HashMap map1 = new HashMap();
map1.put("Name", name[i]);
map1.put("ID", id[i]);
map1.put("Course", course[i]);
map1.put("Score", score[i]);
map1.put("PY", py[i]);
mylist.add(map1);
}
SpecialAdapter adapter = new SpecialAdapter(this, mylist,
R.layout.main, new String[] {"PY", "Course", "Score",
"ID", "Name" }, new int[] {R.id.a07_ls_txtSNSRE, R.id.a07_ls_txtYNSE, R.id.a07_ls_txtSNSE,
R.id.a07_ls_txtXXSR, R.id.a07_ls_txtYF });
TextView t1 = new TextVIEw(this);
t1.setText("姓名");
t1.setBackgroundResource(R.drawable.bk);
TextView t2 = new TextVIEw(this);
t2.setText("學號");
t2.setBackgroundResource(R.drawable.bk);
TextView t3 = new TextVIEw(this);
t3.setText("科目");
t3.setBackgroundResource(R.drawable.bk);
TextView t4 = new TextVIEw(this);
t4.setText("成績");
t4.setBackgroundResource(R.drawable.bk);
TextView t5 = new TextVIEw(this);
t5.setText("總評");
t5.setBackgroundResource(R.drawable.bk);
LinearLayout linear = new LinearLayout(this);
linear.setBackgroundResource(R.drawable.bg_comment_grey);
linear.addVIEw(t1, 79, 45);
linear.addVIEw(t2, 80, 45);
linear.addVIEw(t3, 80, 45);
linear.addVIEw(t4, 80, 45);
linear.addVIEw(t5, 80, 45);
lv = new ListVIEw(this);
lv.setHorizontalScrollBarEnabled(true);
lv.addHeaderVIEw(linear);// 設置listHeader 始終位於列表頂部
lv.setAdapter(adapter);
HorizontalScrollView hsv = new HorizontalScrollVIEw(this);
hsv.addVIEw(lv);
setContentVIEw(hsv);
// lv = (ListView)findVIEwById(R.layout.main);
// lv.setHorizontalScrollBarEnabled(true);
// lv.setSelector(R.drawable.bg_setting_tablerow);
// lv.setAdapter(adapter);
// setContentVIEw(lv);
}
}
class SpecialAdapter extends SimpleAdapter {
private int[] colors = new int[] { 0x30FF0000, 0x300000FF };
public SpecialAdapter(Context context, List> data,
int resource, String[] from, int[] to) {
super(context, data, resource, from, to);
}
@Override
public View getView(int position, View convertView, VIEwGroup parent) {
View view = super.getView(position, convertVIEw, parent);
int colorPos = position % colors.length;
if (colorPos == 1) {
vIEw.setBackgroundColor(Color.argb(250, 255, 255, 255));
} else {
vIEw.setBackgroundColor(Color.argb(250, 224, 243, 250));
}
return vIEw;
}
}
XML文件
Main.XML
android:layout_width="fill_parent" android:layout_height="fill_parent"
XMLns:android="http://schemas.android.com/apk/res/android" >
android:layout_height="wrap_content" android:id="@+id/listvIEw">
android:layout_height="wrap_content"
android:textColor="#42AF40"
android:drawableRight="@drawable/line_y"
android:id="@+id/a07_ls_txtYF">
android:layout_height="wrap_content"
android:textColor="#42AF40"
android:drawableRight="@drawable/line_y"
android:id="@+id/a07_ls_txtXXSR">
android:layout_width="80dip"
android:layout_height="wrap_content"
android:textColor="#42AF40"
android:drawableRight="@drawable/line_y"
android:id="@+id/a07_ls_txtYNSE">
android:layout_width="80dip"
android:layout_height="wrap_content"
android:textColor="#42AF40"
android:drawableRight="@drawable/line_y"
android:id="@+id/a07_ls_txtSNSE">
android:layout_width="80dip"
android:layout_height="wrap_content"
android:textColor="#42AF40"
android:drawableRight="@drawable/line_y"
android:id="@+id/a07_ls_txtSNSRE">
最近幾天由於項目的需要研究了一下listVIEw的滑動數據動態的更新顯示,其中需要在數據加載過程有圓形進度條的顯示,遇到的問題是進度條的顏色設置,在網上查了一些資料結合
Google近期開始打擊盜版Android軟件,為開發者提供了 License Verification Library (LVL) 方式來防止Android軟件被盜版
在搞個小字典的應用時候,有人提過,不能正常顯示音標問題,經過一番查找,發現是字體問題,android系統自帶的字體都不支持顯示音標,只能自己把支持音標顯示的字體加入項目
package com.example.android.apis.graphics;23.TextAlign: 設置Path路徑,貝賽爾曲線1: