请问我真的需要帮助吗?我需要在我的应用中执行类似的操作
我尝试使用多级列表视图,但是(1,2,3 ..)之类的主要点来自表,而(1.1,1.2 ...)之类的子点来自另一个表
对于主要点,行类
public class meeting_folders {
private String id;
private String folder;
private String meeting;
private String order;
private String active;
public meeting_folders(String id, String folder, String meeting, String order, String active) {
this.id = id;
this.folder = folder;
this.meeting = meeting;
this.order = order;
this.active = active;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFolder() {
return folder;
}
public void setFolder(String folder) {
this.folder = folder;
}
public String getMeeting() {
return meeting;
}
public void setMeeting(String meeting) {
this.meeting = meeting;
}
public String getOrder() {
return order;
}
public void setOrder(String order) {
this.order = order;
}
public String getActive() {
return active;
}
public void setActive(String active) {
this.active = active;
}
}
适配器是这样的:
public class Meetings_folders_adapter extends ArrayAdapter<meeting_folders> {
public ArrayList<meeting_folders> MainList;
public ArrayList<meeting_folders> MeetingListTemp;
Typeface font;
Date currentTime = Calendar.getInstance().getTime();
ArrayList<meeting_folders> MeetingList = new ArrayList<meeting_folders>();
public Meetings_folders_adapter.MeetingDataFilter MeetingDataFilter ;
public Meetings_folders_adapter(Context context, int id, ArrayList<meeting_folders> meetingArrayList) {
super(context, id, meetingArrayList);
this.MeetingListTemp = new ArrayList<meeting_folders>();
this.MeetingListTemp.addAll(meetingArrayList);
this.MainList = new ArrayList<meeting_folders>();
this.MainList.addAll(meetingArrayList);
font = Typeface.createFromAsset(context.getAssets(), "fonts/Droid.Arabic.Kufi_DownloadSoftware.iR_.ttf");
}
@Override
public Filter getFilter() {
if (MeetingDataFilter == null){
MeetingDataFilter = new Meetings_folders_adapter.MeetingDataFilter();
}
return MeetingDataFilter;
}
public class ViewHolder {
TextView Code;
}
@SuppressLint("InflateParams") @Override
public View getView(int position, View convertView, ViewGroup parent) {
Meetings_folders_adapter.ViewHolder holder = null;
if (convertView == null) {
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.meeting_folders_row, null);
holder = new Meetings_folders_adapter.ViewHolder();
holder.Code = (TextView) convertView.findViewById(R.id.meeting_title_name);
convertView.setTag(holder);
convertView.setBackgroundColor(Color.WHITE);
} else {
holder = (Meetings_folders_adapter.ViewHolder) convertView.getTag();
}
meeting_folders mob = MeetingListTemp.get(position);
holder.Code.setText(mob.getFolder());
holder.Code.setTypeface(font);
//holder.image.setImageBitmap(Bitmap.createBitmap(bitmaps[Integer.parseInt(CompanyListTemp.get(position).getID())-1]));
// holder.image.setImageBitmap(Bitmap.createBitmap(bitmaps[position]));
return convertView;
}
@SuppressLint("DefaultLocale") private class MeetingDataFilter extends Filter
{
@Override
protected FilterResults performFiltering(CharSequence charSequence) {
charSequence = charSequence.toString().toLowerCase();
FilterResults filterResults = new FilterResults();
if(charSequence != null && charSequence.toString().length() > 0)
{
ArrayList<meeting_folders> arrayList1 = new ArrayList<meeting_folders>();
for(int i = 0, l = MainList.size(); i < l; i++)
{
meeting_folders mob = MainList.get(i);
if(mob.toString().toLowerCase().contains(charSequence))
arrayList1.add(mob);
}
filterResults.count = arrayList1.size();
filterResults.values = arrayList1;
}
else
{
synchronized(this)
{
filterResults.values = MainList;
filterResults.count = MainList.size();
}
}
return filterResults;
}
@SuppressWarnings("unchecked")
@Override
protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
MeetingListTemp = (ArrayList<meeting_folders>)filterResults.values;
notifyDataSetChanged();
clear();
for(int i = 0, l = MeetingListTemp.size(); i < l; i++)
add(MeetingListTemp.get(i));
notifyDataSetInvalidated();
}
}
public static String dateFormater(String dateFromJSON, String expectedFormat, String oldFormat) {
SimpleDateFormat dateFormat = new SimpleDateFormat(oldFormat);
Date date = null;
String convertedDate = null;
try {
date = dateFormat.parse(dateFromJSON);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(expectedFormat);
convertedDate = simpleDateFormat.format(date);
} catch (Exception e) {
e.printStackTrace();
}
return convertedDate;
}
}
活动是这样的:
private class ParseJSonDataClassTiltles extends AsyncTask<Void, Void, Void> {
public Context context;
String FinalJSonResult;
public ParseJSonDataClassTiltles(Context context) {
this.context = context;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... arg0) {
HttpServiceClass httpServiceClass = new HttpServiceClass( URL_FOR_MEETING_FOLDER.concat(iddd));
try {
httpServiceClass.ExecutePostRequest();
if (httpServiceClass.getResponseCode() == 200) {
FinalJSonResult = httpServiceClass.getResponse();
if (FinalJSonResult != null) {
JSONArray jsonArray = null;
try {
jsonArray = new JSONArray();
JSONObject jsonObject= new JSONObject(FinalJSonResult);
jsonArray= jsonObject.getJSONArray("meeting_folder");
for (int i = 0; i < jsonArray.length(); i++) {
meetingList_folders.add(new meeting_folders(jsonArray.getJSONObject(i).getString("id"),
jsonArray.getJSONObject(i).getString("folder"),
jsonArray.getJSONObject(i).getString("meeting"),
jsonArray.getJSONObject(i).getString("order"),
jsonArray.getJSONObject(i).getString("active")));
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
Toast.makeText(context, httpServiceClass.getErrorMessage(), Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
adapter2 = new Meetings_folders_adapter(meeting_details.this, R.layout.meeting_folders_row, meetingList_folders);
listview3.setAdapter(adapter2);
}
}
上面的代码没问题,输出是简单的listView。
现在我需要在每个列表项下执行保存子数据的表???。
如果您还有其他想法,请随时分享
非常感谢...。