private class CurrentEmployeeAdapter extends BaseAdapter {
Context context;
int layoutId;
LayoutInflater liCurrentEmp;
public CurrentEmployeeAdapter(CurrentEmployee currentEmployee, int activity_current_employee) {
this.context=currentEmployee;
this.layoutId=activity_current_employee;
liCurrentEmp=LayoutInflater.from(context);
}
@Override
public int getCount() {
return SalesManNameArrayList.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
View v;
if (convertView==null){
convertView=liCurrentEmp.inflate(R.layout.current_employee_items,parent,false);
v=convertView;
}else {
v=convertView;
}
TextView tvEmpName=(TextView)v.findViewById(R.id.tv_salesman_name);
final TextView tvassingwork=(TextView)v.findViewById(R.id.tv_assign_word);
Button btnAssign=(Button)v.findViewById(R.id.btn_assign);
btnAssign.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
tvassingwork.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (assignNo==1) {
tvassingwork.setText("Assigning");
tvassingwork.setTextColor(getResources().getColor(R.color.green));
assignNo=0;
}else {
int i=position+1;
if(i >0) {
String moveName = SalesManNameArrayList.get(position);
SalesManNameArrayList.set(position, SalesManNameArrayList.get(position));
SalesManNameArrayList.remove(position);
SalesManNameArrayList.add(SalesManNameArrayList.size(), moveName);
tvassingwork.setText("Assigned");
tvassingwork.setTag(position-1);
tvassingwork.setTextColor(getResources().getColor(R.color.red));
assignNo=1;
notifyDataSetChanged();
}
}
}
});
tvEmpName.setText(SalesManNameArrayList.get(position));
return convertView;
}
}
答案 0 :(得分:1)
试试这个
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "de.programmierenlernenhq.aktiehq.app"
minSdkVersion 10
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:24.0.0'
compile 'com.android.support:appcompat-v7:24.0.0'
}
runOnUIThread()可以帮助您。