getView カスタム リストビューの合計カウントを取得しようとしています。でも違うレイアウトで表示したい。これが私のonCreatedViewです。レイアウトを膨らませる方法がわかりません。ご助力いただきありがとうございます。
private static ListView addDropListView = null;
private TransactionAddDropAdapter addDropAdapter = null;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
fragmentPendingTrades = inflater.inflate(R.layout.fragment_transactions_pending, container, false);
pendingTradesView = inflater;
return fragmentPendingTrades;
}
public void onViewCreated(final View view, final Bundle savedInstanceState) {
this.addDropListView = (ListView) view.findViewById(R.id.transactions_pending_transactionsListView);
this.addDropAdapter = new TransactionAddDropAdapter(pendingTradesView);
this.addDropListView.setAdapter(this.addDropAdapter);
this.emptyTransationsContainer = view.findViewById(R.id.transactions_pending_transactions_emptyContainer);
TextView getTotalCount = (TextView) view.findViewById(R.id.transactions_pending_TransactionsAddDropCount);
getTotalCount.setText(""+addDropListView.getCount());
}
これがgetViewを取得する私のHolderviewです
public class TransactionAddDropAdapter extends BaseAdapter {
private LayoutInflater inflater = null;
private List<TransactionAddDrop> addDropList = new ArrayList<TransactionAddDrop>();
public TransactionAddDropAdapter(LayoutInflater inflater) {
this.inflater = inflater;
}
public void setAddDropList(List<TransactionAddDrop> addDropList) {
clearAddDropList();
for (TransactionAddDrop ad : addDropList) {
if (ad.isStateApprove()) {
this.addDropApprovalsList.add(ad);
} else {
this.addDropList.add(ad);
}
}
}
public void clearAddDropList() {
this.addDropList.clear();
this.addDropApprovalsList.clear();
}
@Override
public int getCount() {
int size = this.addDropList.size();
if (this.addDropApprovalsList.size() > 0) {
size += 1;
}
return size;
}
@Override
public Object getItem(int position) {
try {
if (this.addDropList == null) {
return null;
} else if (position < addDropList.size()) {
return this.addDropList.get(position);
} else {
return this.addDropApprovalsList;
}
} catch (Exception e) {
return null;
}
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(final int position, View convertView,
ViewGroup parent) {
final TransactionAddDrop addDropData = this.addDropList.get(position);
TransactionAddDropViewHolder holder = null;
if (convertView == null) {
convertView = inflater.inflate(R.layout.fragment_pending_transaction_list_item, null);
holder = new TransactionAddDropViewHolder();
holder.withdrawButton = convertView.findViewById(R.id.pendingTransactionItem_withdrawButton);
holder.addContainer = (LinearLayout) convertView.findViewById(R.id.pendingTransactionItem_addContainer);
holder.dropContainer = (LinearLayout) convertView.findViewById(R.id.pendingTransactionItem_dropContainer);
holder.rootView = convertView.findViewById(R.id.swipeRight);
holder.swipeButtons();
convertView.setTag(holder);
} else {
holder = (TransactionAddDropViewHolder) convertView.getTag();
holder.swipeButtons();
}
}