I got to myself. I answer my own question, all of a sudden someone will need it:
My Fragment2.java:
public class Fragment2 extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.five, null); ListView listView = (ListView) v.findViewById(R.id.listView); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { } }); ArrayList<HashMap<String, String>> myArrList = new ArrayList<HashMap<String, String>>(); HashMap<String, String> map; map = new HashMap<String, String>(); map.put("Name", "Алгебра"); map.put("Tel", "4.45"); myArrList.add(map); map=new HashMap<String, String>(); map.put("Name","Английский язык"); map.put("Tel","4.55"); myArrList.add(map); SimpleAdapter adapter = new SimpleAdapter( getActivity(), myArrList, R.layout.row, new String[]{"Name", "Tel"}, new int[]{R.id.text1, R.id.text2}); listView.setAdapter(adapter); return v; } }
Markup on row.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <TextView android:id="@+id/text1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Name" android:textSize="20dp" android:textColor="@color/blue" android:layout_marginTop="20dp" android:layout_marginBottom="20dp" android:layout_marginLeft="10dp"/> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/RelLay" android:layout_marginRight="25dp"> <TextView android:id="@+id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Tel" android:textSize="20dp" android:layout_alignParentRight="true" android:textColor="@color/blue" android:layout_marginTop="20dp" android:layout_marginBottom="20dp" android:textStyle="bold" /> </LinearLayout> </LinearLayout>
OnClickListenermethodonCreate? - temq 3:31 pm