0
我的需求是需要調整或移動從左到右或從右到左的碎片。我的主要佈局包含兩個片段。我需要拖動&調整片段寬度,如android設置屏幕/消息(在平板電腦上)divider從右向左移動或從左向右移動。Android碎片拖動或移動從左到右或從右到左
我的應用程序只考慮平板電腦。 &這兩個片段是獨立地(未掌握細節)
courses_main.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="horizontal"
android:baselineAligned="false" >
<fragment
android:id="@+id/listFragment"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
class="com.mobile.courses.CousesFragment" ></fragment>
<View
android:layout_width="5dp"
android:layout_height="fill_parent"
android:background="@color/list_divider_color" />
<fragment
android:id="@+id/detailFragment"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"
class="com.mobile.whathappenfeed.DiscussionFeedFragment" ></fragment>
</LinearLayout>
CoursesActivity
public class CoursesActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.courses_main);
}
}
這是我的`CourseFragment.java
public class CousesFragment extends Fragment {
private List<Course> courses;
private RefreshableListViewContainer refresh;
private RefreshableListView listView;
protected CourseArrayAdapter courseAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.courses_fragment, container,
false);
refresh = (RefreshableListViewContainer) view
.findViewById(R.id.pull_to_refresh_list);
listView = (RefreshableListView) refresh
.findViewById(android.R.id.list);
// Set a listener to be invoked when the list should be refreshed.
refresh.setOnRefreshListener(new OnRefreshListener() {
public void onRefresh(boolean loading) {
refresh.finishLoading();
reloadCurrentCourses();
}
});
loadAndDisplayCourses();
return view;
}
這是我的DiscussionFragment.java
public class DiscussionFeedFragment extends ListFragment implements OnClickListener {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.discussion_fragment, container,false);
return view;
}
這是我course_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<include
android:id="@+id/list_header_item"
layout="@layout/list_header_item" />
<View
android:padding="4dip"
android:layout_width="fill_parent"
android:layout_height="3dp"
android:background="@color/list_divider_color" />
<include
android:id="@+id/empty_courses"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="@layout/empty_courses"
android:visibility="gone" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<com.mobile.widget.RefreshableListViewContainer
android:id="@+id/pull_to_refresh_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.mobile.widget.RefreshableListViewOverflowItem
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<com.mobile.widget.RefreshableListViewItem
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<com.mobile.widget.RefreshableListView
android:id="@android:id/list"
style="@style/MotorolaListViewFooterFix"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:cacheColorHint="#00000000"
android:paddingLeft="10dip"
android:paddingTop="10dip"
android:divider="@drawable/list_item_divider"
android:dividerHeight="3dp"
android:drawSelectorOnTop="true"
android:fadingEdge="none"
android:smoothScrollbar="true"
android:fastScrollEnabled="false"
android:footerDividersEnabled="true"
android:headerDividersEnabled="true"
android:listSelector="@drawable/item_background_holo_light"
android:textFilterEnabled="true" />
</com.mobile.widget.RefreshableListViewContainer>
</FrameLayout>
</LinearLayout>
我需要調整片段讓向右或從右到左。像主/細節或設置屏幕。但我沒有創建爲主細節應用程序。如何做這部分?
您使用過ViewPager嗎? –
號請告訴我如何在這裏添加ViewPager? – user3391455
我的理解正確,你需要交換兩個片段? –