listview를 지금 짜고 있는데;; 튕겨져 나오는 에러는 수정했건만 이번엔 엉뚱한 오류가 나네요
제가 현재 원하는 출력물이
-------------------------
뭐야 46733
-------------------------
이것인데 현재 출력을 해보면 대충 다음과 같이 나옵니다
-------------------------
뭐야
-------------------------
* '---------'표시는 그냥 보기 편하라고 한 것이니 신경쓰지않으셔도되요
아무튼 이렇게 나오는데.. 도대체 어디서 오류가 난건지 모르겠고.. xml쪽 문제인가 해서 다른쪽 activity에 연결해서 보았으나listview에 연결한 xml자체의 문제는 아닌듯 했습니다 ㅠ
public class ManagementActivity extends Activity {
View pageCash, pageBankbook, pageCheckcard, pageCreditcard;
ArrayList<Bankbook> itemBankbook;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_management);
Button btnBack= (Button)findViewById(R.id.back);
btnBack.setOnClickListener(new OnClickListener() {
public void onClick(View v) { finish(); }
});
pageCash= findViewById(R.id.pageCash);
pageBankbook= findViewById(R.id.pageBankbook);
pageCheckcard= findViewById(R.id.pageCheckcard);
pageCreditcard= findViewById(R.id.pageCreditcard);
findViewById(R.id.btnCash).setOnClickListener(fraimClickListener);
findViewById(R.id.btnBankbook).setOnClickListener(fraimClickListener);
findViewById(R.id.btnCheckcard).setOnClickListener(fraimClickListener);
findViewById(R.id.btnCreditcard).setOnClickListener(fraimClickListener);
findViewById(R.id.btnInsertBankbook).setOnClickListener(editClickListener);
findViewById(R.id.btnInsertCheckcard).setOnClickListener(editClickListener);
findViewById(R.id.btnInsertCreditcard).setOnClickListener(editClickListener);
//데이터 원본 준비
itemBankbook= new ArrayList<Bankbook>();
Bankbook bankbook;
bankbook= new Bankbook("뭐야", 46733 , false ); itemBankbook.add(bankbook);
// bankbook= new Bankbook("된다고", 333, true); itemBankbook.add(bankbook);
//어댑터 준비
AdapterListBankbook BankbookAdapter= new AdapterListBankbook(this, R.layout.listview_bankbook, itemBankbook);
ListView ListBankbook;
ListBankbook= (ListView)findViewById(R.id.listBankbook);
ListBankbook.setAdapter(BankbookAdapter);
}
}
//리스트뷰에 출력할 항목
class Bankbook{
Bankbook(String bName, int bBalance, boolean bInclude) {
BName= bName;
BBalance= bBalance;
BInclude= bInclude;
}
String BName;
int BBalance;
boolean BInclude;
}
//어댑터 클래스
class AdapterListBankbook extends BaseAdapter{
Context maincon;
LayoutInflater Inflater;
ArrayList<Bankbook> arSrc;
int layout;
public AdapterListBankbook(Context context, int alayout, ArrayList<Bankbook> aarSrc) {
maincon= context;
Inflater= (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
arSrc= aarSrc;
layout= alayout;
}
public int getCount(){ return arSrc.size(); }
public String getItem(int position){ return arSrc.get(position).BName; }
public long getItemId(int position){ return position; }
//각 항목의 뷰 생성
public View getView(int position, View convertView, ViewGroup parent){
final int pos= position;
if(convertView== null){
convertView= Inflater.inflate(layout, parent, false);
}
TextView textBankbookName= (TextView)convertView.findViewById(R.id.bankbookName);
textBankbookName.setText(arSrc.get(position).BName);
TextView textBankbookBalance= (TextView)convertView.findViewById(R.id.bankbookBalance);
textBankbookBalance.setText(Integer.toString(arSrc.get(position).BBalance));
//TextView textBankbookInclude= (TextView)convertView.findViewById(R.id.bankbookInclude);
//textBankbookInclude.setText(arSrc.get(position).BBalance);
return convertView;
}
}