Android ListView没有';t填充

Android ListView没有';t填充,android,listview,loader,Android,Listview,Loader,这是我做的一个简单的Android项目。我在运行时没有收到任何警告或错误。但是ListView没有被填充。我不明白出了什么问题 由于我不明白确切的问题出在哪里,复制粘贴所有代码也无济于事,以下是我的项目代码存储库: 任何形式的帮助都将不胜感激 MSKFragment.java public class MSKFragment extends android.support.v4.app.Fragment implements android.support.v4.app.LoaderManage

这是我做的一个简单的Android项目。我在运行时没有收到任何警告或错误。但是ListView没有被填充。我不明白出了什么问题

由于我不明白确切的问题出在哪里,复制粘贴所有代码也无济于事,以下是我的项目代码存储库:

任何形式的帮助都将不胜感激

MSKFragment.java

public class MSKFragment extends android.support.v4.app.Fragment implements android.support.v4.app.LoaderManager.LoaderCallbacks<Cursor>
{
private ServiceAdapter mServiceAdapter;

public static final int SERVICE_LOADER = 0;

private static final String[] SERVICE_COLUMNS =
        {
                ServiceContract.ServiceEntry.TABLE_NAME,
                ServiceContract.ServiceEntry._ID,
                ServiceContract.ServiceEntry.COLUMN_NAME,
                ServiceContract.ServiceEntry.COLUMN_ORGANIZATION_NAME,
                ServiceContract.ServiceEntry.COLUMN_PRICE
        };


public static final int COL_ID = 0;
public static final int COL_NAME = 1;
public static final int COL_ORG_NAME = 2;
public static final int COL_PRICE = 3;

public MSKFragment()
{

}

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    getLoaderManager().initLoader(SERVICE_LOADER, null, this);
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
{
    inflater.inflate(R.menu.menu_fragment_msk, menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
    int id = item.getItemId();

    if (id == R.id.action_refresh)
    {
        //Moving functions to a helper class, so that when Activity starts the data can be displayed
        updateServices();
        return true;
    }

    return super.onOptionsItemSelected(item);
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState)
{
    mServiceAdapter = new ServiceAdapter(getActivity(), null, 0);

    View rootView = inflater.inflate(R.layout.fragment_msk, container, false);

    ListView listView = (ListView) rootView.findViewById(R.id.listViewMainService);

    listView.setAdapter(mServiceAdapter);

    return rootView;
}

@Override
public void onStart()
{
    super.onStart();
    //Refresh called and service updated when activity starts
    updateServices();
}

//Calling FetchServiceTask and executing it.
private void updateServices()
{
    FetchServicesTask serviceTask = new FetchServicesTask(getActivity());
    serviceTask.execute();
}

@Override
public android.support.v4.content.Loader<Cursor> onCreateLoader(int i, Bundle args)
{
    Uri serviceUri = ServiceContract.ServiceEntry.buildServiceUri(i);
    return new android.support.v4.content.CursorLoader(getActivity(), serviceUri, null, null, null, null);
}

@Override
public void onLoadFinished(android.support.v4.content.Loader<Cursor> loader, Cursor data)
{
    mServiceAdapter.swapCursor(data);
}

@Override
public void onLoaderReset(android.support.v4.content.Loader<Cursor> loader)
{
    mServiceAdapter.swapCursor(null);
}

}
public class ServiceAdapter extends CursorAdapter
{
public ServiceAdapter(Context context, Cursor c, int flags)
{
    super(context, c, flags);
}

private String convertCursorRowToUXFormat(Cursor cursor)
{

    return cursor.getString(MSKFragment.COL_NAME) + "-" + cursor.getString(MSKFragment.COL_ORG_NAME) +
            " - " + cursor.getInt(MSKFragment.COL_PRICE);
}

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent)
{
    View view = LayoutInflater.from(context).inflate(R.layout.list_item_main, parent, false);
    return view;
}

@Override
public void bindView(View view, Context context, Cursor cursor)
{
    TextView tv = (TextView)view;
    tv.setText(convertCursorRowToUXFormat(cursor));
}
}

ServiceAdapter.java中的方法newView()更改为:

public View newView(Context context, Cursor cursor, ViewGroup parent){
View view = LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_1, parent, false);
return view;}

如果你需要帮助,你必须向我们展示更多的代码。请在问题中发布你的相关代码。请在初始化listview和适配器的位置发布代码。我已经按照你们的要求完成了。必须提供代码,以便很容易找到答案。
public View newView(Context context, Cursor cursor, ViewGroup parent){
View view = LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_1, parent, false);
return view;}