这里有滑动标签的麻烦。所以我已经完成了教程,但当我有一个ListView到我的寻呼机时,它只显示在屏幕的底部。
这是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.example.ambidata.innovway.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:background="@android:color/white"/>
</LinearLayout>
我的ListView中的XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/issue_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="@color/list_divider"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_row_selector"/>
</LinearLayout>
片段代码:
public class TabIssues extends Fragment {
private ListView mainListView ;
private CustomListAdapter_Issues listAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle b = getArguments();
int user_id = b.getInt("user_id");
boolean all = b.getBoolean("all");
WSConnectionIssues runner = new WSConnectionIssues(user_id, all);
runner.execute();
while (runner.download == AsyncTask.Status.RUNNING)
{
try
{
Thread.sleep(1);
} catch (Exception ex)
{
ex.printStackTrace();
}
}
View view = inflater.inflate(R.layout.activity_issues, container, false);
// Find the ListView resource.
mainListView = (ListView) view.findViewById(R.id.issue_list);
registerForContextMenu(mainListView);
// Create ArrayAdapter using the planet list.
View convertView = inflater.inflate(R.layout.row_issues, null);
listAdapter = new CustomListAdapter_Issues(this, runner.listIssues, convertView);
// Set the ArrayAdapter as the ListView's adapter.
mainListView.setAdapter(listAdapter);
return view;
}
我正在使用手机进行调试...因为你可以看到空白...然后我的列表视图中的第一项,如果你滚动其他项目就在那里!
答案 0 :(得分:0)
您可以将listview布局尝试为:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/issue_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:divider="@color/list_divider"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_row_selector"/>
</RelativeLayout>