package com.whitebyte.hotspotcontrolexample;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.view.View.OnClickListener;
import android.widget.*;
import com.whitebyte.hotspotclients.R;
import com.whitebyte.wifihotspotutils.ClientScanResult;
import com.whitebyte.wifihotspotutils.WifiApManager;
public class Main extends Activity implements OnItemClickListener {
WifiApManager wifiApManager;
ListView m_list_view;
ArrayList<ClientScanResult> result;
ClientAdapter m_adapter;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
m_list_view = (ListView)findViewById(R.id.id_clientList);
wifiApManager = new WifiApManager(this);
result = new ArrayList<ClientScanResult>();
result.add(new ClientScanResult("test1" ,"test1"));
result.add(new ClientScanResult("test2" ,"test2"));
m_adapter = new ClientAdapter(result);
m_list_view.setAdapter(m_adapter);
}
class ClientAdapter extends BaseAdapter {
private ArrayList<ClientScanResult> object;
public ClientAdapter(ArrayList<ClientScanResult> object){
super();
this.object = object;
}
public int GetCount(){
return object.size();
}
public Object getItem(int position){
return null;
}
public long getItemid(int position){
return 0;
}
public View getView(int position, View convertView, ViewGroup parent){
ViewHolder holder;
if(convertView == null){
LayoutInflater inflater = LayoutInflater.from(Main.this);
convertView = inflater.inflate(R.layout.list_item,parent,false);
holder = new ViewHolder();
holder.txtDev = (TextView)convertView.findViewById(R.id.txtDev);
holder.txtIP = (TextView)convertView.findViewById(R.id.txtIP);
convertView.setTag(holder);
}
else{
holder = (ViewHolder)convertView.getTag();
}
String device = object.get(position).getDevice();
String ipAddress = object.get(position).getIpAddr();
holder.txtDev.setText(device);
holder.txtIP.setText(ipAddress);
return convertView;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
}
static class ViewHolder{
TextView txtDev;
TextView txtIP;
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<View android:background="#ff0000"
android:layout_width="fill_parent"
android:layout_height="4px" />
<ListView android:id="@+id/id_clientList"
android:layout_width="fill_parent"
android:layout_height="320px"
android:drawSelectorOnTop="false" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
android:orientation="horizontal"
android:paddingTop="5px"
android:paddingBottom="5px"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/txtDev"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp"/>
<TextView
android:id="@+id/txtIP"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="13sp"/>
</LinearLayout>
</LinearLayout>
안녕하세요 책에서 리스트뷰에 뷰홀더를 써서 출력한는 예제를 따라하는중인데요
이상하게 화면에 아무것도 나타나지 않습니다
문법적으론 문제가 없는데 어디가 문제인지 모르겠습니다ㅜ
레이아웃이 문제인것도 같아서 레이아웃도 첨부합니다