Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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="horizontal"
- android:descendantFocusability="blocksDescendants">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/station_name"
- android:padding="10dp"
- android:textColor="#eee345"
- android:textAppearance="?android:textAppearanceLarge"
- />
- <ImageButton android:id="@+id/favorite"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:src="@drawable/start"
- android:background="#00ffffff"
- />
- </LinearLayout>
- public class Fragmentone extends Fragment{
- ArrayList<String> name;
- boolean isPressed=false;
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_one, container, false);
- name=new ArrayList<String>();
- name.add("First Station");
- name.add("Second Station");
- ListView listView = (ListView) view.findViewById(R.id.list_view);
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- String item = (String) parent.getItemAtPosition(position);
- Toast.makeText(getActivity(), "Item : " + item, Toast.LENGTH_SHORT).show();
- }
- });
- ArrayAdapter arrayAdapter =new ArrayAdapter(getActivity(),R.layout.row_layout,R.id.station_name,name);
- listView.setAdapter(arrayAdapter);
- return view;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement