Tôi đang sử dụng các đoạn trong ứng dụng của mình. Đây là đoạn đầu tiên của tôi mà chỉ đơn giản thổi phồng một tập tin xml:Cách chuyển Gói từ Fragment đến Fragment
public class FragmentA extends SherlockFragment
{
Context myContext,appContext;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
myContext = getActivity();
appContext=getActivity().getApplicationContext();
arguments = getArguments();
doctor_id=arguments.getInt("doctor_id");
userType=arguments.getString("userType");
return inflater.inflate(R.layout.left_panel, container,false);
}
và đây là .xml left_panel, có chứa một đoạn:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/titles"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
class="com.example.sample.ListFrag" />
</LinearLayout>
Đây là lớp ListFrag tôi:
public class ListFrag extends Fragment
{
Context myContext,appContext;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
layoutView = inflater.inflate(R.layout.activity_doctor_list,container);
myContext = getActivity();
appContext=getActivity().getApplicationContext();
arguments=getArguments();
int doctor_id=arguments.getInt("doctor_id");
}
}
Tôi không biết cách vượt qua Bundle arguments
từ FragmentA đến ListFrag.
tôi không tạo ListFrag từ FragmentA .. tôi đang sử dụng Fragment trong tệp xml và sau đó thổi phồng tệp xml đó từ FRagment A. – Vikky
sau đó blackbelt, bên dưới, có giải pháp cho bạn – gunar
sry ....... .... ý bạn là gì?? – Vikky