我有扩展片段的类
public class oUnit extends Fragment {
我想填充列表并将其添加到线性布局,所以我使用以下代码
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ProgressDialog connectionProgressDialog = new
ProgressDialog( getActivity());
connectionProgressDialog.setCancelable(false);
connectionProgressDialog.setCanceledOnTouchOutside(false);
connectionProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
connectionProgressDialog.setMessage("Uploading Leads...");
connectionProgressDialog.show();
View view = inflater.inflate(
R.layout.chemounit,
container,
false);
//Intialize the record Grid
LinearLayout formLayout = (LinearLayout)view.findViewById(R.id.UnitGrid);
formLayout.removeAllViews();
MainGrid = new ListView(getActivity().getApplicationContext());
MainGrid.setVisibility(ListView.VISIBLE);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.RIGHT;
MainGrid.setLayoutParams(params);
//2. Call the web Service
GlobalVariables appState = (GlobalVariables) getActivity().getApplication();
Log.d(" in Chemo unit"," the array is has "+ appState.encounters.size());
MainGrid.setAdapter(new Encounteradapter(view.getContext(),R.id.ChemoUnitGrid , appState.encounters));
// Finally add it
formLayout.addView(MainGrid);
connectionProgressDialog.dismiss();
return view;
}
我确定全局变量列表不为空并且包含数据(我用来log.d
显示它的长度),适配器类就像
public class Encounteradapter extends ArrayAdapter<Encounter> {
private final Context context;
TextView textViewTime ;
TextView textViewPatientName;
Button ButottonArrive ;
Button ButottonEncounter;
Button ButottonExit;
ArrayList<Encounter> Encounters ;
public Encounteradapter(Context context, int ResourceId,
ArrayList<Encounter> items)
{
super(context, ResourceId, items);
this.context = context;
this.Encounters = items ;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.chemounitgrid, parent, false);
Encounter EncounterObject = Encounters.get(position);
textViewTime = (TextView) rowView.findViewById(R.id.Time);
textViewTime.setText(EncounterObject.bookingDate);
textViewPatientName = (TextView) rowView.findViewById(R.id.Time);
textViewPatientName.setText(EncounterObject.Name);
ButottonArrive = (Button) rowView.findViewById(R.id.test1);
ButottonEncounter = (Button) rowView.findViewById(R.id.test2);
ButottonExit = (Button) rowView.findViewById(R.id.test3);
rowView.setTag(position);
return rowView;
}
}
但没有出现列表没有出现,我也尝试删除我设置的属性部分,但也没有
这是我尝试在片段 OnCreate() 上显示进度的第二个问题,但它没有出现我使用以下代码
connectionProgressDialog = new ProgressDialog(getActivity());
connectionProgressDialog.setCancelable(false);
connectionProgressDialog.setCanceledOnTouchOutside(false);
connectionProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
connectionProgressDialog.setMessage("Uploading Leads...");
connectionProgressDialog.show();
知道如何解决这个问题,我是否错过了片段中的任何内容