how to refresh a layout - java

i want to remove added textfields and add other ones based on what is selected from a spinner.
here is my code:
in xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#f4f4f4"
android:id="#+id/taskoptionfragmentlinearlayout" >
<TextView
android:layout_marginTop="10dp"
android:textStyle="bold"
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select A Search Option" />
<Spinner
android:layout_marginTop="20dp"
android:id="#+id/gis_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
in class:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
final View rootView = inflater.inflate(R.layout.fragment_tasklist_options, container, false);
#Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
ll = (LinearLayout)rootView.findViewById(R.id.taskoptionfragmentlinearlayout);
//create textfields....
TextView tv = new TextView(getActivity());
tv.setText(INPUTFLDLABELAArray.get(i));
tv.setGravity(Gravity.RIGHT);
tv.setTextSize(18);
tv.setTypeface(Typeface.DEFAULT_BOLD);
tv.setPadding(0, 0, 15, 0);
ll.addView(tv);
}
i summarized the code to make it short.
so when an item in spinner is selected, the textfield shows. then when another item is selected, a textfield shows under the previous textfield. so what i want is to (refresh/reset) the layout so that every time an item is selected, the old textfield is removed and the new one is added.

try calling ll.removeAllViews() before adding the new ones

Related

Scroll all the screen when use gridview with other items

I have a fragment that displays some items "images and buttons"
I want to scroll all the screen, not just the gridview, I made some search and used some codes but it is sold not working, so how can I do that.......
..................................................................................
...................................................................................
Here is the problem 4 sec
my codes
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:overScrollMode="never"
android:scrollbars="none"
tools:context=".Fragment.ImagesFragmentProject.HomeImagesFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<!-- editor's chooses text -->
<TextView
android:id="#+id/choose_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/scrollView_image"
android:paddingTop="20dp"
android:paddingRight="10dp"
android:paddingBottom="6dp"
android:text="إختيار المحررين"
android:textColor="#color/colorBlack"
android:textSize="18sp"
android:textStyle="bold" />
<GridView
android:id="#+id/gridview_image_choose"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="#id/choose_text2"
android:background="#fff"
android:columnWidth="100dp"
android:fastScrollEnabled="false"
android:gravity="center"
android:horizontalSpacing="0dp"
android:numColumns="auto_fit"
android:paddingTop="8dp"
android:scrollbars="none"
android:stretchMode="columnWidth"
android:verticalSpacing="0dp" />
</RelativeLayout>
Java class
public class HomeImagesFragment extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
/* ArrayList for chooseImages */
final String[] chooseImages = {
"https://i1.wp.com/www.newphotodownload.info/wp-content/uploads/2018/12/%D8%A8%D9%88%D8%B3%D8%AA%D8%A7%D8%AA-%D8%AF%D9%8A%D9%86%D9%8A%D8%A9-61-1.jpg",
"https://quotess.cc/wp-content/uploads/2020/01/4688.jpg",
"https://whatt.cc/wp-content/uploads/2018/07/4443.jpg",
"https://i1.wp.com/www.newphotodownload.info/wp-content/uploads/2018/12/%D8%A8%D9%88%D8%B3%D8%AA%D8%A7%D8%AA-%D8%AF%D9%8A%D9%86%D9%8A%D8%A9-61-1.jpg",
"https://quotess.cc/wp-content/uploads/2020/01/4688.jpg",
"https://whatt.cc/wp-content/uploads/2018/07/4443.jpg",
"https://i1.wp.com/www.newphotodownload.info/wp-content/uploads/2018/12/%D8%A8%D9%88%D8%B3%D8%AA%D8%A7%D8%AA-%D8%AF%D9%8A%D9%86%D9%8A%D8%A9-61-1.jpg"
};
/* make new object and find the view "GridView" */
GridView gridview1 = rootView.findViewById(R.id.gridview_image_choose);
// display all the images from Array on it
gridview1.setAdapter(new PicassoImagesAdapter(getActivity(), chooseImages));
/* display the image when click on it */
// we made a class for this method called "PicassoDisplayImageAdapter"
gridview1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// get the image
String image = chooseImages[position];
Intent intent = new Intent(getActivity(), PicassoDisplayImageAdapter.class);
intent.putExtra("imageUrl", image);
getActivity().startActivity(intent);
}
});
return rootView;
}
}

Want to open WebView in each list item click?

I Want to open a static HTML file in each click of List item but when i call my listview is disappeared . please help me to short out this problem.
My Tab1Fragment.java Code is this
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_tab1, container, false);
Resources res = getResources();
mainTopic = res.getStringArray(R.array.MainTopic);
mainDescription = res.getStringArray(R.array.DescriptionContent);
listView = (ListView) view.findViewById(R.id.listView);
MyAdapter myAdapter = new MyAdapter(getActivity(), mainTopic, image1,
mainDescription);
listView.setAdapter(myAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
wb=(WebView)view.findViewById(R.id.webView);
wb.loadUrl("file:///assets/ActivePassive.html");
wb.getSettings().setJavaScriptEnabled(true);
wb.setWebViewClient(new WebViewClient());
}
}
});
return view;
}
}
My fragment_tab1.xml code is :-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="androidthirst.company.abhi.totalenglish.Tab1Fragment">
<!-- TODO: Update blank fragment layout -->
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/listView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
And my separate listView code is this
single_row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#1A237E"
android:gravity="center"
android:textStyle="bold"
android:textSize="30sp"
android:layout_margin="9dp"
android:textColor="#ffffff"
android:id="#+id/imageView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/imageView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="#+id/textView2"
android:layout_toRightOf="#+id/imageView"
android:layout_below="#+id/textView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBottom="#+id/imageView" />
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/webView">
</WebView>
</RelativeLayout>
Here you can see the image i just want to open thml file in first list Item Click
Try Bellow code:
list_Id.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
list_Id.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
WebView webView = new WebView(v.getContext());
String[] urls = getResources().getStringArray(R.array.bookmark_urls);
webView.loadUrl(urls[position]);
}
});
}
});
Create a file string-array.xml inside values and put all web addresses as bellow:
<resources>
<string-array name="bookmark_urls">
<item>http://www.google.com</item>
<item>http://www.android.com/</item>
<item>http://www.facebook.com/</item>
<item>http://www.android.com/</item>
<item>http://www.android.com/</item>
</string-array>
</resources>
you can use something like below
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Your layout is "fragment_tab1"
View view = inflater.inflate(R.layout.fragment_tab1, container, false);
While you wrot layout name "My tab1_fragment.xml code is :-"
please check is that exact layout?
And your Webview is in Row file which used in adapter class.. (single_row.xml)
You tried to load in activity..
Thanks abhi..

Button at the bottom of a long ListView in a DialogFragment can't be seen

IF the ListView has a lot of children and she needs to scroll i can't see the dismiss button at the end of the FragmentDialog.
Here you can see the Dismiss Button:
And in the long ListView you can't see at the bottom the Dismiss Button:
dialog.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/dialog_header_text_view_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/dialog_header_text_view_text"
android:textSize="22sp"
android:textColor="#color/opening_words_dialog_header_color"
android:layout_marginBottom="15sp"
android:textStyle="bold"
/>
<ListView
android:id="#+id/dialog_list_view_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/dialog_header_text_view_id"
/>
<Button
android:id="#+id/dialog_dismiss_button_id"
android:layout_width="100sp"
android:layout_height="50sp"
android:text="#string/list_view_button_footer_text"
android:layout_below="#+id/dialog_list_view_id"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
CustomDialogFragment.java:
public class CustomDialogFragmentYearsKnownLoveMails extends DialogFragment
{
TextView listViewItemTextView;
ArrayAdapter<String> arrayAdapter;
ListView dialogListView;
String[] items = new String[120];
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.dialog, container,false);
setCancelable(false);
listViewItemTextView = (TextView) rootView.findViewById(R.id.list_view_item_text_view_id);
dialogListView = (ListView) rootView.findViewById(R.id.dialog_list_view_id);
dissmissDialogButton = (Button) rootView.findViewById(R.id.dialog_dismiss_button_id);
for (int i = 0;i < items.length;i++)
{
items[i] = "" + (i + 1);
}
arrayAdapter = new ArrayAdapter<String>(LoveMailsActivity.this, R.layout.list_view_row,R.id.row_text_view_id,items);
dialogListView.setAdapter(arrayAdapter);
dialogListView.setOnItemClickListener(new OnItemClickListener()
{
#Override
public void onItemClick(AdapterView<?> parent, View view,int position, long id)
{
Toast.makeText(getActivity(), items[position], Toast.LENGTH_SHORT).show();
loveEmailYearsKnownTextView.setText(items[position]);
}
});
dissmissDialogButton.setOnClickListener(new View.OnClickListener() // Dismiss button click
{
#Override
public void onClick(View v)
{
dismiss();
}
});
return rootView;
}
}
So what's wrong with it?
if you need any more info just ask.
The list view, by the constraints above and below, is "stretch" from the bottom (i.e. base line) of the text view to the top of the button. Usually I start to write the component which touch the parent view (i.e. align parent top/bottom) and finish with the view in the middle as this view list.
The trick is to expand the list below the textview and above the button like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/dialog_header_text_view_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/dialog_header_text_view_text"
android:textSize="22sp"
android:textColor="#color/opening_words_dialog_header_color"
android:layout_marginBottom="15sp"
android:textStyle="bold"
/>
<Button
android:id="#+id/dialog_dismiss_button_id"
android:layout_width="100sp"
android:layout_height="50sp"
android:text="#string/list_view_button_footer_text"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
/>
<ListView
android:id="#+id/dialog_list_view_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/dialog_header_text_view_id"
android:layout_above="#id/dialog_dismiss_button_id"
/>
</RelativeLayout>
For listview in XML change attribute layout_below to layout_above ="#id/dialog_dismiss_button_id"
And remove layout_below attribute from Button. And Add this to button
android:layout_alignParentBottom="true"
Hope this helps you :)

Weird behaviour of ListView

When I add an item below the "ADD ITEM BELOW" comment as shown below, my onItemLongClick and ListItemClick cannot work. However once I've removed the items below the "ADD ITEM BELOW", it will work. What's wrong?
<?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:background="#color/caldroid_transparent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/event_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/event_list_margin"
android:layout_marginBottom="#dimen/event_list_margin"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="80dp"
android:layout_height="80dp"
android:orientation="vertical"
android:layout_marginLeft="#dimen/standard_margin_size">
<TextView
android:id="#+id/event_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20"
android:gravity="center"
android:layout_centerHorizontal="true"
android:textColor="#color/caldroid_black"
android:textSize="45dp" />
<TextView
android:id="#+id/event_month_year"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="JAN 2015"
android:textSize="12dp"
android:gravity="center"
android:layout_below="#id/event_day"
android:textColor="#color/caldroid_black" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="#dimen/standard_padding_size"
android:paddingBottom="#dimen/standard_padding_size"
android:paddingLeft="#dimen/feed_item_profile_info_padd"
android:paddingRight="#dimen/feed_item_profile_info_padd"
android:layout_marginLeft="#dimen/feed_item_profile_info_padd"
android:layout_marginRight="#dimen/feed_item_profile_info_padd"
android:id="#+id/event_set_colour">
<TextView
android:id="#+id/event_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Title"
android:textStyle="bold"
android:textColor="#color/caldroid_black"
android:textSize="#dimen/standard_text_size" />
<TextView
android:id="#+id/event_location"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="local"
android:layout_below="#id/event_title"
android:textColor="#color/caldroid_black"
android:textSize="#dimen/feed_item_profile_name" />
<TextView
android:id="#+id/event_start_end_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/event_location"
android:text="28 May 2015, Saturday"
android:textColor="#color/caldroid_black"
android:textSize="#dimen/feed_item_profile_name" />
</RelativeLayout>
</LinearLayout>
<!-- ADD ITEM BELOW -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"/>
</LinearLayout>
EventFragment.java
public class EventFragment extends ListFragment {
//Set database to allow user to retrieve data to populate EventFragment.java
private AppointmentController appointmentDatabase;
//List to get all the appointments
private List<Appointment> allAppointment;
EventAdapter adapter;
Appointment selected_appointment;
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Get all the appointment
appointmentDatabase = new AppointmentController(getActivity());
appointmentDatabase.open();
allAppointment = appointmentDatabase.getAllAppointment();
//Initialise ArrayAdapter adapter for view
adapter = new EventAdapter(getActivity(), R.layout.row_event, allAppointment);
setListAdapter(adapter);
getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
#Override
public boolean onItemLongClick(AdapterView<?> arg0, View view, int position, long id) {
// remove code for simplicity
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_listfragment, container, false);
return rootView;
}
#Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// remove code for simplicity
}
If you wants to make onItemClick work add
android:descendantFocusability="blocksDescendants"
to the parent layout something like it:-
<?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:background="#color/caldroid_transparent"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">
</LinearLayout>
when you blocksDescendants then you can not get onClick event on
Button in row of ListView. Basically you can get event on either row
or Button in a row.
Try changing:
#Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// remove code for simplicity
}
to
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public boolean onItemClick(AdapterView<?> arg0, View view, int position, long id) {
// whatever code would have been above put in here
}

ListFragment OnItemClickListener

I have a list fragment displaying my custom list items which consist of a relative layout containing images and text etc.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/main_background"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="10dp"
android:descendantFocusability="blocksDescendants" >
<ImageView
android:id="#+id/source_image"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#color/black"
android:layout_alignParentLeft="true"
android:contentDescription="#string/info" />
<TextView
android:id="#+id/item_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:textStyle="bold"
android:layout_toRightOf="#+id/source_image"
android:textColor="#color/black"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:textAlignment="center"
android:text="#string/item_desc" />
<ImageView
android:id="#+id/arrow_image"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="30dp"
android:layout_alignParentRight="true"
android:contentDescription="#string/info"
android:src="#drawable/arrow_right" />
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:layout_centerInParent="true"
android:background="#color/main_background"
android:layout_below="#+id/item_description">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/white"
android:layout_gravity="fill_horizontal"
android:layout_marginRight="20dp"
android:padding="5dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/item_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/info"
android:src="#drawable/chameleon" />
<ImageView
android:id="#+id/item_image2"
android:paddingLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/info"
android:gravity="center"
android:src="#drawable/chameleon" />
<ImageView
android:id="#+id/item_image3"
android:paddingLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/info"
android:gravity="center"
android:src="#drawable/chameleon" />
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
I am trying to set up an OnItemClickListener so when the user clicks anywhere on the list item, a new Intent is started.
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//Populate list view with array objects
adapter = new HomeListItemAdapter(items, getActivity());
listView = getListView();
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Toast toast = Toast.makeText(listView.getContext(), "CLICKED", Toast.LENGTH_SHORT);
toast.show();
}
});
}
I am attempting this as shown above but can't seem to get the OnItemClickListener to work (just testing with Toast instead of Intent for now). Where am I going wrong?
Thanks
EDIT: Added custom list adapter code
public class HomeListItemAdapter extends BaseAdapter {
private List<HomeListItem> items;
private Context context;
private int numItems = 0;
public HomeListItemAdapter(final List<HomeListItem> items, Context context) {
this.items = items;
this.context = context;
this.numItems = items.size();
}
public int getCount() {
return numItems;
}
public HomeListItem getItem(int position) {
return items.get(position);
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
// Get the current list item
final HomeListItem item = items.get(position);
// Get the layout for the list item
final RelativeLayout itemLayout = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.list_item, parent, false);
// Set the the item picture(s)
ImageView itemImage = (ImageView) itemLayout.findViewById(R.id.item_image);
itemImage.setImageDrawable(item.getItemPic());
//Set the profile picture / source picture
ImageView sourceImage = (ImageView) itemLayout.findViewById(R.id.source_image);
sourceImage.setImageDrawable(item.getSourcePic());
// Set the text label as defined in our list item
TextView itemDesc = (TextView) itemLayout.findViewById(R.id.item_description);
AssetManager am = context.getAssets();
Typeface font = Typeface.createFromAsset(am, "Raleway-Thin.ttf");
itemDesc.setTypeface(font);
itemDesc.setText(item.getText());
return itemLayout;
}
}
Try extending ListFragment (instead of just a normal Fragment). Then you can override onListItemClicked:
public void onListItemClick(ListView l, View v, int pos, long id)
This gives you the list, view, position, and id, so you should be able to do whatever you need.
Could you try setting the HozizontalScrollView to not get focus with the XML attribute
android:focusable="false"
If you have a TextView inside the row then that will take focus when the row is clicked. This will mean that onListItemClick is not called. You either need to have an OnClickListener on the TextView or remove focus from the TextView.
See ListFragment OnListItemClick not being called
Try this sample project for costum ListFragment. It is a very good example with a costum ListFragment showing 2 types of views for phone and tablets.
http://s000.tinyupload.com/index.php?file_id=09444774931653041243
Courtsey
http://jcrazyandroider.blogspot.in/2015/01/download-links.html

Categories

Resources