int end = path.lastIndexOf(“.”);
return path.substring(start+1,end);
}
3.activity_face_manage.xml
中新增代码:
<com.guo.android_extend.widget.HListView
android:id=“@+id/hlistView”
android:layout_width=“wrap_content”
android:layout_height=“100dp”
android:layout_alignParentBottom=“true”
android:layout_centerHorizontal=“true”
android:scrollbars=“none”
app:dividerHeight=“1dp”
app:listSelector=“@android:drawable/list_selector_background”
android:layout_gravity=“center_horizontal”/>
<TextView
android:id=“@+id/tv_number”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_gravity=“center_horizontal”
android:textSize=“30dp”
android:textColor=“#000000”/>
4.FaceManageActivity.java
中新增代码:
…
private HListView mHListView;
public RegisterViewAdapter mRegisterViewAdapter;
…
mHListView = (HListView) findViewById(R.id.hlistView);
TextView facenum = (TextView) findViewById(R.id.tv_number);
downFile();
mRegisterViewAdapter = new RegisterViewAdapter(FaceManageActivity.this);
mHListView.setAdapter(mRegisterViewAdapter);
…
private void downFile()
{
int faceNum = FaceServer.getInstance().getFaceNumber(this);
if (faceNum == 0) {
showToast(getString(R.string.batch_process_no_face_need_to_delete));
}else {
FaceServer.getInstance().getImgAndName(this);
}
}
…
class Holder {
ExtImageView siv;
TextView tv;
}
class RegisterViewAdapter extends BaseAdapter {
Context mContext;
LayoutInflater mLInflater;
public RegisterViewAdapter(Context c) {
mContext = c;
mLInflater = LayoutInflater.from(mContext);
}
@Override
public int getCount() {
if (FaceServer.faceImgRegisterInfoList==null){
return 0;
}else {
facenum.setText(“注册的人脸数:” + FaceServer.faceImgRegisterInfoList.size() + “个”);
return FaceServer.faceImgRegisterInfoList.size();
}
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder = null;
if (convertView != null)
holder = (Holder) convertView.getTag();
else {
convertView = mLInflater.inflate(R.layout.item_sample, null);
holder = new Holder();
holder.siv = (ExtImageView) convertView.findViewById(R.id.imageView1);
holder.tv = (TextView) convertView.findViewById(R.id.textView1);
convertView.setTag(holder);
}
if (!(FaceServer.faceImgRegisterInfoList == null)){
if (!FaceServer.faceImgRegisterInfoList.isE