I was testing TabActivity with a list in each tab.
While running the app, the contents of the tabs gets overlapped like this.
After i click on the tabs the overlapping gets cleared.
Here is my code :
testtabs.xml layout :
<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#+id/list1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
<ListView
android:id="#+id/list2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
</FrameLayout>
</LinearLayout>
</TabHost>
And Test Activity
public class TabbedActivity extends TabActivity {
private static final String LIST1_TAB_TAG = "List1";
private static final String LIST2_TAB_TAG = "List2";
private ListView listView1;
private ListView listView2;
private TabHost tabHost;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.testtabs);
tabHost = getTabHost();
// setup list view 1
listView1 = (ListView) findViewById(R.id.list1);
// create some dummy strings to add to the list
List<String> list1Strings = new ArrayList<String>();
list1Strings.add("List 11");
list1Strings.add("List 12");
list1Strings.add("List 13");
list1Strings.add("List 14");
listView1.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, list1Strings));
// setup list view 2
listView2 = (ListView) findViewById(R.id.list2);
List<String> list2Strings = new ArrayList<String>();
list2Strings.add("Test2 List 21");
list2Strings.add("Testing 22");
list2Strings.add("More test 23");
list2Strings.add("Test Again 24");
listView2.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list2Strings));
// add views to tab host
tabHost.addTab(tabHost.newTabSpec(LIST1_TAB_TAG).setIndicator(LIST1_TAB_TAG).setContent(new TabContentFactory() {
public View createTabContent(String arg0) {
return listView1;
}
}));
tabHost.addTab(tabHost.newTabSpec(LIST2_TAB_TAG).setIndicator(LIST2_TAB_TAG).setContent(new TabContentFactory() {
public View createTabContent(String arg0) {
return listView2;
}
}));
tabHost.setCurrentTab(0);
}
}
You can remove both ListView from xml layout and just create them in java code.
e.g. listView1 = new ListView(this);
Everything will be Ok.
Another solution I found is to add the following tag to both the listviews in the layout XML file:
android:visibility="invisible"
You are taking two ListView's in a FrameLayout that is the reason for your over-lapping.
If you want that you should have one ListView below the other keep the ListView's inside the LinearLayout like this,
<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#+id/list1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
<ListView
android:id="#+id/list2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
Related
having a trouble here with the sliding tabs. So I have completed the tutorial but when i had a ListView to my Pager it only shows on the bottom of the screen.
Here is my XML:
<?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="vertical">
<com.example.ambidata.innovway.SlidingTabLayout
android:id="#+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:background="#android:color/white"/>
</LinearLayout>
And my XML from ListView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/issue_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#color/list_divider"
android:dividerHeight="1dp"
android:listSelector="#drawable/list_row_selector"/>
</LinearLayout>
Fragment Code:
public class TabIssues extends Fragment {
private ListView mainListView ;
private CustomListAdapter_Issues listAdapter;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle b = getArguments();
int user_id = b.getInt("user_id");
boolean all = b.getBoolean("all");
WSConnectionIssues runner = new WSConnectionIssues(user_id, all);
runner.execute();
while (runner.download == AsyncTask.Status.RUNNING)
{
try
{
Thread.sleep(1);
} catch (Exception ex)
{
ex.printStackTrace();
}
}
View view = inflater.inflate(R.layout.activity_issues, container, false);
// Find the ListView resource.
mainListView = (ListView) view.findViewById(R.id.issue_list);
registerForContextMenu(mainListView);
// Create ArrayAdapter using the planet list.
View convertView = inflater.inflate(R.layout.row_issues, null);
listAdapter = new CustomListAdapter_Issues(this, runner.listIssues, convertView);
// Set the ArrayAdapter as the ListView's adapter.
mainListView.setAdapter(listAdapter);
return view;
}
Im using the phone for debug...as you can see blank...then the first item of my listview and if you scroll the others are there!
Could you try the listview layout as:
<?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"
android:orientation="vertical" >
<ListView
android:id="#+id/issue_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:divider="#color/list_divider"
android:dividerHeight="1dp"
android:listSelector="#drawable/list_row_selector"/>
</RelativeLayout>
So I have a ListView inside my TabHost and I want to redrow its content every time I change the tab. Nevertheless I never get the list drawed.
My xml file looks like:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
<!-- Dishes Panel -->
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/dishSelector"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
tools:context=".MenuSelectorActivity" />
</LinearLayout>
</TabHost>
And my TabActivity:
public class MenuSelectorActivity extends TabActivity implements TabHost.TabContentFactory{
private ListView dishSelector;
private DishSelectorAdapter dishSelectorAdapter;
private TabHost tabHost;
private DishDao dishDao;
private DishTypeDao dishTypeDao;
private Map<Integer, List<DishPojo>> dishesByType;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu_selector);
tabHost = getTabHost(); // The activity TabHost
tabHost.setup();
TabHost.TabSpec spec;
dishDao = new DishDao(this);
dishTypeDao = new DishTypeDao(this);
dishesByType = new HashMap<Integer, List<DishPojo>>();//new ArrayList<List<DishPojo>>();
List<DishType> types = dishTypeDao.list();
TextView dTypeNameView;
for(DishType dType : types){
dishesByType.put(dType.getId().hashCode(), createDishPojoList(dishDao.list(
new String[]{DishDbContract.SQL_WHERE_CLAUSE_LIST_BY_TYPE}, new String[]{dType.getId()})));
}
tabHost.setCurrentTab(0);
for(DishType dType : types){
dTypeNameView = new TextView(this);
dTypeNameView.setText(dType.getDescription());
spec = tabHost.newTabSpec(dType.getId()).setIndicator(dTypeNameView).setContent(this);
tabHost.addTab(spec);
}
}
#Override
public View createTabContent(String tag) {
dishSelector = (ListView) findViewById(R.id.dishSelector);
if(dishSelectorAdapter == null){
dishSelectorAdapter = new DishSelectorAdapter(this, dishesByType.get(tag.hashCode()));
}else{
dishSelectorAdapter.setDishToSelect(dishesByType.get(tag.hashCode()));
}
dishSelector.setAdapter(dishSelectorAdapter);
dishSelector.refreshDrawableState();
return dishSelector;
}
private List<DishPojo> createDishPojoList(List<Dish> dishes){
//creates a list of Pojos
}
}
The adpter DishSelectorAdapter has been already used in other situation and it works ok, so I don't think it is relevant here.
Thanks by hand.
Well well, it was not as hard as I've thought. The answer was just in front of my eyes.
I didn't put the ListView inside de FrameLayout. The correct code will be:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
<!-- Dishes Panel -->
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/dishSelector"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
tools:context=".MenuSelectorActivity" />
</FrameLayout>
</LinearLayout>
</TabHost>
Still rest of the code has some issues to work about, but nothing I coudln't fix with a quick look.
I have 4 tabs and in 1 of the tabs (tab 3) I have a list with 2 options. Is there a way to start a new activity when I click one of the options? I tried changing Activity to ListActivity but my app crashes as soon as it loads. Would I need to implement something else to this for it to work?
code:
public class MainActivity extends Activity implements OnClickListener{
TabHost th;
ListView libraryView;
String libraryList[] = {"Item1", "Item2"};
#Override
public void onCreate(Bundle savedInstanceState) {
//Always do this at the start.
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_white_text, R.id.library_list_content, libraryList);
libraryView = (ListView) findViewById(R.id.listView1);
libraryView.setAdapter(adapter);
//Creating the TabHost and gathering its ID for usage.
th = (TabHost) findViewById(R.id.tabhost);
th.setup();
TabSpec specs = th.newTabSpec("tag1");
specs.setContent(R.id.tab1);
specs.setIndicator("tab1");
th.addTab(specs);
specs = th.newTabSpec("tag2");
specs.setContent(R.id.tab2);
specs.setIndicator("tab2");
th.addTab(specs);
specs = th.newTabSpec("tag3");
specs.setContent(R.id.tab3);
specs.setIndicator("tab3");
th.addTab(specs);
specs = th.newTabSpec("tag4");
specs.setContent(R.id.tab4);
specs.setIndicator("tab4");
th.addTab(specs);
}
#Override
public void onClick(View v) {
switch(v.getId()){
case R.id.listView1:
}
XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TabHost
android:id="#+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/black" >
<LinearLayout
android:id="#+id/tab1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</LinearLayout>
<LinearLayout
android:id="#+id/tab2"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</LinearLayout>
<LinearLayout
android:id="#+id/tab3"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="#+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/tab4"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</LinearLayout>
</FrameLayout>
<TabWidget android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_marginBottom="-4dp" >
</TabWidget>
</LinearLayout>
</TabHost>
</RelativeLayout>
Add on click listeners for listview like this
ListView list = (ListView) findViewById(R.id.listView1);
list.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// depending on item positions create intents for activity.
}
});
I am trying to put a MapActivity and a ListActivity in Tabs. I found a way of doing it, but I just don't like the way it looks like (I rather use some classes to make my code more modular)
Now, I have this code in my main activity:
Resources res = getResources(); // Resource object to get Drawables
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
intent = new Intent().setClass(this, OptionsActivity.class);
spec = tabHost.newTabSpec(OPTS_TAB_TAG).setIndicator("Options",
res.getDrawable(R.drawable.ic_tab_options))
.setContent(intent);
tabHost.addTab(spec);
And this one in the OptionsActivity class:
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class OptionsActivity extends ListActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] options = getResources().getStringArray(R.array.options_array);
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, options));
ListView lv = getListView();
lv = (ListView) findViewById(R.id.opt);
lv.setEmptyView((TextView) findViewById(R.id.options));
lv.setTextFilterEnabled(true);
lv.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, options));
}
}
and my layout main.xml:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/main">
<ListView
android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<TextView
android:id="#+id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"/>
<ListView
android:id="#+id/opt"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<TextView
android:id="#+id/options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"/>
</LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0fFbO-eNMhj2lDaC6b4YBfpo1DikBMixPYiEJCw" />
</RelativeLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
But for some reason, when I select this "Options" tab, my application has a force close...
Can someone show me what I'm doing wrong here?
you are not using any layout so from where you are getting lv = (ListView) findViewById(R.id.opt); put code in try catch block like this
try{
ListView lv = getListView();
lv = (ListView) findViewById(R.id.opt);
lv.setEmptyView((TextView) findViewById(R.id.options));
lv.setTextFilterEnabled(true);
lv.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, options));
}catch(Exception e){
e.getMessage(); ///Put break point here to find error
}
then debug it once
I am having a silly problem with a OnItemCliskListener for my ListView. It works well when the XML is very simple but after I improve its complexity, the OnItemCliskListener stop working
In other words, I have a ListView with just a TextView. But if I turn my ListView into a more complex list with other TextView, an Icon a CheckBox, the ClickListener stop working.
If I run exactly the same code changing just the XML, the OnItemCliskListener stops working. I would be rather grateful if you could help me
WORKING LIST VIEW:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="vertical"
android:layout_height="fill_parent">
<TextView android:id="#+id/title"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_toLeftOf="#+id/appCheck"
android:layout_toRightOf="#+id/appIcon"
android:textAppearance="?android:attr/textAppearanceLarge">
</TextView>
</RelativeLayout>
NOT WORKING LISTVIEW:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="vertical"
android:layout_height="fill_parent">
<ImageView android:src="#drawable/icon" android:id="#+id/appIcon"
android:layout_width="30px" android:layout_height="40px"></ImageView>
<CheckBox android:id="#+id/appCheck"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true"></CheckBox>
<TextView android:id="#+id/title"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_toLeftOf="#+id/appCheck"
android:layout_toRightOf="#+id/appIcon"
android:textAppearance="?android:attr/textAppearanceLarge">
</TextView>
<TextView android:id="#+id/subtitle"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_toLeftOf="#+id/appCheck"
android:layout_toRightOf="#+id/appIcon" android:layout_below="#+id/title"
android:textAppearance="?android:attr/textAppearanceSmall">
</TextView>
</RelativeLayout>
MY JAVA ACTIVITY:
public class MyTabsActivity extends TabActivity implements OnTabChangeListener {
private static final String LIST3_TAB_TAG = "List3";
private RelativeLayout layoutTab3;
private MyArrayAdapter adapterListViewTab3;
private TabHost tabHost;
...
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tabHost = getTabHost();
tabHost.setOnTabChangedListener(this);
...
...
// ----------------- BUILD TAB3
// That is my Tab of Running App
layoutTab3 = (RelativeLayout) findViewById(R.id.running_app_relative_layout);
// Fill my ListView of Running App
ListView runningAppList = (ListView) findViewById(R.id.running_app_listview);
List<String> list3Strings = new ArrayList<String>();
list3Strings.add("Item 1");
list3Strings.add("Item 2");
list3Strings.add("Item 3");
list3Strings.add("Item
adapterListViewTab3 = new MyArrayAdapter(this, android.R.layout.simple_list_item_1, list3Strings);
runningAppList.setAdapter(adapterListViewTab3);
// ????????????????????????????????????????????????????????????????????????????????????????????
// >>>>>>>>>>>> THIS OnItemClickAdapter DOESN'T WORK !!!!! WHY ????????
runningAppList.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(MyTabsActivity.this, "EUREKA", Toast.LENGTH_SHORT).show();
}
});
...
// add Tab3
TabSpec tab3 = tabHost.newTabSpec(LIST3_TAB_TAG).setIndicator(LIST3_TAB_TAG).setContent(new TabContentFactory() {
public View createTabContent(String arg0) {
return layoutTab3;
}
});
tabHost.addTab(tab3);
layoutTab3.setVisibility(View.INVISIBLE);
...
}
}
MY R.layout.main:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TabWidget android:id="#android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<FrameLayout android:id="#android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ListView android:id="#+id/list1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1">
</ListView>
<ListView android:id="#+id/list2" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1">
</ListView>
<RelativeLayout android:id="#+id/running_app_relative_layout"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal"
android:id="#+id/coco" android:layout_alignParentTop="true"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ListView android:id="#+id/running_app_listview"
android:scrollbars="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_gravity="fill_vertical"
android:layout_alignParentTop="true"></ListView>
</LinearLayout>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
I've figured out that when a custom ListView contains focusable elements, onListItemClick won't work (I think it's the expected behaviour). So I've just removed the focus from the custom view and it did the trick. In other words, I added the following commands to my view:
android:focusable="false"
android:focusableInTouchMode="false"
The full explanation is avaiable here: How to fire onListItemClick in Listactivity with buttons in list?