स्क्रॉल नहीं करता है मैंने एक ऐप बनाया जिसमें दो टुकड़े हैं और दोनों टुकड़ों में सूचीदृश्य हैं। खंड 1 में पहली सूचीदृश्य स्क्रॉल हो रहा है और आइटम भी हाइलाइट किए जा रहे हैं। लेकिन दूसरे खंड में, सूचीदृश्य स्क्रॉल नहीं किया गया है और यहां तक कि आइटम हाइलाइट नहीं हो रहे हैं। क्या कोई मुझे बता सकता है कि समस्या क्या है? यहां बात यह है कि मैंने एक्सएमएल में दोनों टुकड़ों में एक ही खंड वर्ग को रखने के साथ इसे अभी चेक किया है। या तो वे दोनों काम करना चाहिए या दोनों को नहीं करना चाहिए क्योंकि कोई दूसरे से अलग नहीं है। लेकिन यह समस्या क्यों होती है?सूचीफ्रेम में दूसरी सूचीदृश्य
मेरे टुकड़ा वर्ग:
public class Fragment1 extends ListFragment{
String[] countries = new String[] {
"India",
"Pakistan",
"Sri Lanka",
"China",
"Bangladesh",
"Nepal",
"Afghanistan",
"North Korea",
"South Korea",
"Japan"
};
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.inflate(R.layout.fragment1,container,false);
}
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,countries);
setListAdapter(adapter);
}
public void onListItemClick(ListView parent, View v,int position, long id)
{
Toast.makeText(getActivity(), "You have selected "+countries[position], Toast.LENGTH_SHORT).show();
}
}
main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:name="com.example.listfragmentexample.Fragment1"
android:id="@+id/fragment1"
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="200dp" />
<fragment
android:name="com.example.listfragmentexample.Fragment1"
android:id="@+id/fragment2"
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="300dp"/>
</LinearLayout>
fragment1.xml:
<LinearLayout 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/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawSelectorOnTop="false"/>
</LinearLayout>
हां। धन्यवाद। जब मैं दूसरी सूचीदृश्य को स्क्रॉल करने का प्रयास करता हूं, तो यह स्क्रॉल नहीं हो रहा है, भले ही मैं कर्सर रखूं और उसके आइटम पर क्लिक किया हो। तो, मैं उलझन में आया, लेकिन काम खींचें। कोई बात नहीं। ठीक है, दूसरे को हाइलाइट करने के लिए आपके सुझाव को लागू करने का प्रयास करेंगे। – Korhan