0
ここに私の最初の断片です...ここで私は4つのフラグメントbtを持っています私はそれをschrollそれを表示するときにのみ表示.. basically私はこの活動reamainig 3つの細かい.in最初のフラグメントは、私はあなたのサービス応答の成功方法でnotifyDataSetChangeを追加することを忘れWebサービスフラグメントのListViewにデータが表示されません。それはスクロール時に表示されます
public class Home_Fr extends ListFragment {
int a;
int i=0;
String[][] radioname;
String[][] radio_id;
String[][] radio_img;
String[] catname;
ListView lv;
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View frag= inflater.inflate(R.layout.home_fr, container, false);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
String name = preferences.getString("categories_id", "");
String[] cat_id=name.split("-");
Log.d("ye id milli ya ni",cat_id[0]);
radioname=new String[cat_id.length][3];
radio_img=new String[cat_id.length][3];
catname=new String[cat_id.length];
radio_id=new String[cat_id.length][3];
for(a=0;a<cat_id.length;a++)
{
getdata(cat_id[a], a);
}
lv= (ListView)frag.findViewById(android.R.id.list);
lv.setAdapter(new HomeFr_listAdepter(getActivity(), catname, radioname, radio_img, radio_id));
return frag;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
}
private void getdata(String k, final int l) {
final ProgressDialog loading = ProgressDialog.show(getActivity(), "Fetching Data", "Please wait...", false, false);
RestAdapter adapter = new RestAdapter.Builder()
.setEndpoint("http://api.dirble.com/v2/category/"+k)
.build();
RadioListApi api = adapter.create(RadioListApi.class);
api.getCategories_id(new Callback<List<RadioListModel>>() {
@Override
public void success(final List<RadioListModel> list, Response response) {
loading.dismiss();
catname[l]=list.get(0).getName();
for (int j = 0; j < 3; j++) {
ImageModel im = list.get(j).getImage();
radio_img[l][j] = im.getUrl();
radioname[l][j] = list.get(j).getName();
radio_id[l][j] = list.get(j).getId();
}
}
@Override
public void failure(RetrofitError error) {
//you can handle the errors here
}
});
}
}
onCreateメソッドでアダプタを空のリストで初期化し、Webサービスが正常に終了したら、notifydatasetchangeを呼び出すことができます。 –
あなたのアダプターがヌルでない場合、あなたの成功方法にnotifydatasetchangeを書くことを試みるかもしれません –
yashirに感謝....それは働いています –