Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/listRow"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:paddingTop="3dp"
android:paddingBottom="3dp">
<TextView android:id="@+id/writeDate"
android:layout_width="wrap_content"
android:layout_height="fill_parent"/>
<TextView android:id="@+id/title"
android:paddingLeft="5dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
Java
private class ListAdapter extends SimpleAdapter{
private ArrayList<HashMap<String, String>> arrayList;
private int resource; // Layout ID
public ListAdapter(Context context,
ArrayList<HashMap<String, String>> data, int resource,
String[] from, int[] to) {
super(context, data, resource, from, to);
this.arrayList = data;
this.resource = resource;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(resource, null);
}
LinearLayout listRow = (LinearLayout)convertView.findViewById(R.id.listRow);
TextView writeDate = (TextView)convertView.findViewById(R.id.writeDate);
TextView title = (TextView)convertView.findViewById(R.id.title);
listRow.setTag(arrayList.get(position).get("link"));
listRow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String link = (String)v.getTag();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link)));
}
});
writeDate.setText(arrayList.get(position).get("writeDate"));
title.setText(arrayList.get(position).get("title"));
return convertView;
}
}
'Android' 카테고리의 다른 글
title 우측에 progress 출력 (0) | 2011.11.17 |
---|---|
앱에서 내장 브라우저 직접 호출 (0) | 2011.11.16 |
ListView안에 ScrollView 삽입 (0) | 2011.11.16 |
알림음 (0) | 2011.09.20 |
현재 사용중인 네트웍 종류 반환 (0) | 2011.09.20 |