728x90
반응형
package com.example.cm_bowling;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
public class Main_Adapter extends BaseAdapter {
LayoutInflater mInflater;
Context context;
ArrayList<String> name;
ArrayList<Integer> game1;
ArrayList<Integer> game2;
ArrayList<Integer> game3;
ArrayList<String> rank;
int mode;
Main_inter inter;
public Main_Adapter(Context context,ArrayList<String> name, ArrayList<Integer>game1, ArrayList<Integer>game2, ArrayList<Integer>game3, ArrayList<String>rank, int mode, Main_inter inter){
this.context = context;
this.name = name;
this.game1 = game1;
this.game2 = game2;
this.game3 = game3;
this.rank = rank;
this.mode =mode;
this.inter =inter;
mInflater = LayoutInflater.from(this.context);
}
@Override
public int getCount() {
return name.size();
}
@Override
public Object getItem(int position) {
return name.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.list_item, parent, false);
holder.layout_Edit = convertView.findViewById(R.id.layout_Edit);
holder.list_edit_name = convertView.findViewById(R.id.list_edit_name);
holder.list_edit_game1 = convertView.findViewById(R.id.list_edit_game1);
holder.list_edit_game2 = convertView.findViewById(R.id.list_edit_game2);
holder.list_edit_game3 = convertView.findViewById(R.id.list_edit_game3);
holder.layout_Text = convertView.findViewById(R.id.layout_Text);
holder.list_text_name = convertView.findViewById(R.id.list_text_name);
holder.list_text_game1 =convertView.findViewById(R.id.list_text_game1);
holder.list_text_game2 =convertView.findViewById(R.id.list_text_game2);
holder.list_text_game3 =convertView.findViewById(R.id.list_text_game3);
convertView.setTag(holder);
}else{
holder = (ViewHolder)convertView.getTag();
}
if (mode == 0){// 수정 모드
holder.layout_Edit.setVisibility(LinearLayout.VISIBLE);
holder.layout_Text.setVisibility(LinearLayout.GONE);
}
else{
holder.layout_Text.setVisibility(LinearLayout.VISIBLE);
holder.layout_Edit.setVisibility(LinearLayout.GONE);
}
return convertView;
}
public class ViewHolder{
LinearLayout layout_Edit;
EditText list_edit_name;
EditText list_edit_game1;
EditText list_edit_game2;
EditText list_edit_game3;
LinearLayout layout_Text;
TextView list_text_name;
TextView list_text_game1;
TextView list_text_game2;
TextView list_text_game3;
}
}
728x90
반응형
'Android' 카테고리의 다른 글
BottomNavigationView + frameLayout (fragment) (0) | 2020.04.25 |
---|---|
인텐트 플래그 (0) | 2020.04.18 |
안드로이드 앱내에서 언어변경 (0) | 2020.04.07 |
안드로이드 키보드 설정 ( 뷰가 밀려날때 ) (0) | 2020.02.23 |
안드로이드 커스텀뷰 2) onDraw 방식 (0) | 2020.02.10 |