I writing test application and I get a strange behavior of mainActivity.listItem, when I click on item yet another item can get visible,it can get dissapear by scrolling.I'm confused.Thanks!
MainActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
stethoInit();
mainActivity = DataBindingUtil.setContentView(this, R.layout.activity_main);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
cursor = getContentResolver().query(MyProvider.CONTENT_URI, null, null, null, null, null);
}
String[] from = new String[]{MyProvider.ID, MyProvider.TEXT};
int[] to = new int[]{R.id.t_id, R.id.t_text};
scAdapter = new SimpleCursorAdapter(this, R.layout.item, cursor, from, to, 0);
mainActivity.listItem.setAdapter(scAdapter);
scAdapter.notifyDataSetChanged();
mainActivity.listItem.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
FrameLayout v = (FrameLayout)view.findViewById(R.id.updateLayout);
Log.d("!!!",v.toString());
v.setVisibility(View.VISIBLE);
}
});
mainActivity.insert.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Fragment insertFragment = new Insert();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, insertFragment);
ft.addToBackStack(null);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commit();
}
});
}
item.xml
<LinearLayout 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:orientation="vertical" >
<FrameLayout
android:id="#+id/updateLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<!-- TODO: Update blank fragment layout -->
<EditText
android:id="#+id/updateTextField"
android:layout_width="match_parent"
android:layout_height="50dp"
android:ems="10"
android:hint="#string/insertTextFieldHint"
android:focusable="false"
android:inputType="textPersonName" />
<Button
android:id="#+id/uodateRecButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="125dp"
android:layout_marginTop="65dp"
android:focusable="false"
android:text="#string/updateRecButton" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"/>
<TextView
android:id="#+id/t_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="#+id/t_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
UPDATE
I solved this problem by extending SimpleCursorAdapter ,maybe someone share with another solution?
private class MyAdapter extends SimpleCursorAdapter{
private int layout;
public MyAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
super(context, layout, c, from, to, flags);
this.layout = layout;
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
String id = cursor.getString(colId);
String title = cursor.getString(colText);
TextView idView = (TextView)view.findViewById(R.id.t_id);
idView.setText(id);
TextView textView = (TextView)view.findViewById(R.id.t_text);
textView.setText(title);
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View view = getLayoutInflater().inflate(layout,parent,false);
return view;
}
#Override
public int getItemViewType(int position) {
return position;
}
#Override
public int getViewTypeCount() {
return getCount();
}
}
Related
I am new to android . I have an application working with listview and i want to number each list view item.
Like,
1 list item
2 list item
3 list item
MainActivity.java
public class MainActivity extends AppCompatActivity {
private OrderDbManager orderDbManager;
private ListView listView;
private SimpleCursorAdapter adapter;
final String[] from = new String[] { OrderDbHelper.FOOD_NAME,
OrderDbHelper.QUANTITY, OrderDbHelper.PRICE };
final int[] to = new int[] {R.id.tvFoodName, R.id.tvItemQuantity, R.id.tvItemPrice };
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
orderDbManager = new OrderDbManager(this);
orderDbManager.open();
final Cursor cursor = orderDbManager.fetch();
listView = (ListView) findViewById(R.id.listView);
listView.setEmptyView(findViewById(R.id.empty));
adapter = new SimpleCursorAdapter(this, R.layout.list_item, cursor, from, to, 0);
adapter.notifyDataSetChanged();
LayoutInflater layoutInflater = getLayoutInflater();
listView.addHeaderView(layoutInflater.inflate(R.layout.cart_header,listView, false));
listView.setAdapter(adapter);
}
public class MyAdapter extends SimpleCursorAdapter {
public MyAdapter(Context context, int layout, Cursor c,
String[] from,int[] to) {
super(context, layout, c, from, to);
}
#Override
public int getCount() {
return 0;
}
#Override
public Object getItem(int arg0) {
return null;
}
#Override
public long getItemId(int arg0) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater layoutInflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.list_item, null, true);
TextView txt= (TextView) convertView.findViewById(R.id.tvSlNo);
txt.setText(position + 1);
return convertView;
}
}
}
activity_main.xml
<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" >
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
list_item.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="wrap_content"
android:layout_margin="5dp"
android:minHeight="50dp"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="#+id/tvSlNo"
android:layout_width="0dip"
android:layout_height="match_parent"
android:gravity="center"
android:textStyle="normal"
android:textColor="#android:color/black"
android:layout_weight="0.1" />
<TextView
android:id="#+id/tvFoodName"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:textStyle="normal"
android:textColor="#android:color/black"
android:text=""/>
<TextView
android:id="#+id/tvItemQuantity"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.15"
android:textStyle="normal"
android:textColor="#android:color/black"
android:gravity="center"/>
<TextView
android:id="#+id/tvItemPrice"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:gravity="center"
android:textStyle="normal"
android:textColor="#android:color/black"
android:text=""/>
</LinearLayout>
i want to set numbering in tvSlNo.
please help
In your getView() method of your listViewAdapter simply use the position variable and set it on your TextView. You may need to add 1 to the position since it starts with 0. So use (position+1) and then set it to your TextView
Though this question may be too late but for other reference purposes.
Check where you have this code: txt.setText(position + 1);
you are close to your solution. You just have to typecast position + 1 to String since setText() only take String alone.
My app has listview inside dialogueFragment , when user chose item it should Toast , in my case items unclickable .
DialogueFragment
public class HistoryDialogue extends DialogFragment {
ListView list ;
Cursor c ;
HistoryAdapter adapter ;
Context context ;
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.history,null);
list = (ListView)view.findViewById(R.id.listView);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
ContentResolver resolver = getActivity().getContentResolver();
c=resolver.query(Contract.SaveRunning.CONTENT_URI,null,null,null,null);
adapter= new HistoryAdapter(getActivity(),c,0);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getActivity(),"keep going ",Toast.LENGTH_LONG).show();
}
});
builder.setView(list);
return builder.create();
}
}
CursorAdapter
public class HistoryAdapter extends CursorAdapter {
public HistoryAdapter(Context context, Cursor c, int flags) {
super(context,c, flags);
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return LayoutInflater.from(context).inflate(R.layout.historylist, parent, false);
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
TextView text = (TextView) view.findViewById(R.id.text);
String body = cursor.getString(cursor.getColumnIndex("name"));
text.setText(body);
}
}
history.xml
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/listView"
android:layout_gravity="center_horizontal" />
historylist.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/text"
android:layout_margin="5dp"
android:layout_weight="1"/>
<Button
android:layout_width="30dp"
android:layout_height="35dp"
android:background="#drawable/delete"
android:id="#+id/btn"
android:layout_margin="10dp"
android:layout_weight="0"
/>
Add android:focusable="false" in your ListView (in history.xml ) and Item main layout (in historylist.xml).
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:focusable="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/listView"
android:layout_gravity="center_horizontal" />
and
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:focusable="false"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp">
...
Add this line to your CursorAdapter's bindView:
((ViewGroup)row).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
if it isn't enough, add clickable="false" to your historylist.xml's Button
I have sqlite database that have table(benefits) and designed like this
recipe percent name ID
1 100 Digestion 1
1 80 Lower ch 2
1 60 Immune sys 3
I want to create list that have two item.
first is name that i have no problem with
second is percent that i want to show like progress bar.
this is what i wrote to do this.
public class BenefitsFragment extends Fragment {
private JuiceDatabase db;
public String data;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_benefits, container, false);
db = new JuiceDatabase(super.getActivity());
//Ingredients Code
Cursor benefits = db.getbenefitsresult();
String[] from = new String[]
{"name","percent"};
int[] to = new int[]
{R.id.input,R.id.progressbar};
final SimpleCursorAdapter myadapter = new CustomSimpleCursorAdapter(
super.getActivity(),
R.layout.ingredients,
benefits,
from,
to);
final ListView list1 = (ListView) rootView.findViewById(R.id.list1);
list1.setAdapter(myadapter);
list1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (calculateHeight(list1))));
return rootView ;
}
private int calculateHeight(ListView list) {
int height = 0;
for (int i = 0; i < list.getCount(); i++) {
View childView = list.getAdapter().getView(i, null, list);
childView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
height+= childView.getMeasuredHeight();
}
//dividers height
height += list.getDividerHeight() * (list.getCount()+5);
return height;
}
}
fragment_benefits.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:scrollbars="none">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/group"
android:layout_marginRight="15sp"
android:layout_marginLeft="15sp"
android:layout_marginTop="15sp"
android:layout_marginBottom="15sp"
android:elevation="15dp">
<TextView
android:id="#+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingRight="5sp"
android:paddingLeft="5sp"
android:paddingTop="5sp"
android:paddingBottom="10sp"
android:text="benefits"
android:textSize="22sp"
android:textColor="#color/dark_grey"
android:gravity="center_horizontal" />
<View style="#style/divider1"/>
<ListView
android:id="#+id/list1"
android:layout_width="fill_parent"
android:layout_height="0sp"
android:scrollbars="none"
android:paddingTop="5sp"
android:paddingLeft="5sp"
android:paddingRight="5sp"
android:layout_marginBottom="5sp"
android:layout_weight="1"
android:clickable="false">
</ListView>
</LinearLayout>
</LinearLayout>
ingredients.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true">
<TextView
android:id="#+id/input"
android:layout_width="fill_parent"
android:layout_height="#dimen/list_name_height"
android:layout_alignWithParentIfMissing="true"
android:textSize="12sp"
android:textColor="#color/dark_grey"
android:gravity="center_vertical|center"
android:background="#android:color/transparent"
android:elevation="8sp"
android:elegantTextHeight="false"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ProgressBar
android:id="#+id/progressbar"
android:layout_width="fill_parent"
android:layout_height="20sp"
android:layout_below="#+id/input"
android:textSize="25sp"
android:longClickable="false"
style="#android:style/Widget.ProgressBar.Horizontal">
</ProgressBar>
CustomSimpleCursorAdabtor.class
public class CustomSimpleCursorAdapter extends SimpleCursorAdapter {
public CustomSimpleCursorAdapter(Context context, int layout, Cursor c, String[] from,
int[] to) {
super(context, layout, c, from, to);
}
public void bindView(View view, Context context, Cursor cursor) {
super.bindView(view, context, cursor);
updateProgressbar(view, cursor);
}
private void updateProgressbar(View view, Cursor cursor) {
ProgressBar progressBar = (ProgressBar) view
.findViewById(R.id.progressbar);
progressBar.setMax(100);
progressBar.setProgress(cursor.getInt(cursor
.getColumnIndex("percent")));
}
}
CursorAdaptor
public Cursor getbenefitsresult(){
SQLiteDatabase db = this.getReadableDatabase();
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
String data=StoreData.data;
String sqlTables = "benefits";
qb.setTables(sqlTables);
Cursor c = db.rawQuery("SELECT 0 _id, name, percent FROM benefits WHERE recipe ="+data,null);
c.moveToFirst();
Log.d("percent",Integer.toString(c.getInt(c
.getColumnIndex("percent"))));
db.close();
return c;
}
After run the program when i click this fragment tab it go back to previous page!!!
whats the problem ?
sorry if its noobish question this is my first app.
EDIT 1:
public class MainRecipe extends FragmentActivity implements
ActionBar.TabListener {
private ViewPager viewPager;
private TabsPagerAdapter mAdapter;
private ActionBar actionBar;
// Tab titles
private String[] tabs = { "مواد لازم", "ارزش غذایی", "فواید" };
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_recipe);
// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Adding Tabs
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name)
.setTabListener(this));
}
/**
* on swiping the viewpager make respective tab selected
* */
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
#Override
public void onPageSelected(int position) {
// on changing the page
// make respected tab selected
actionBar.setSelectedNavigationItem(position);
}
#Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
#Override
public void onPageScrollStateChanged(int arg0) {
}
});
}
#Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
#Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
}
#Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}
}
I found thee problem myself.
that was in CustomSimpleCursorAdapter
I must used setProgressbar instead of updateprogressbar .
I want to add an button to the footer of listview, I'm using horizontal listview, The adapter class:
public ItemAdapter(Context context, int layout, Cursor c,String[] from, int[] to) {
super(context, layout, c, from, to,0);
this.layout = layout;
inflator= LayoutInflater.from(context);
}
I return the newView and bindView:
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View v = inflator.inflate(layout, parent, false);
TextView footer = (TextView)v.findViewById(R.id.bAdd);
return v;
}
#Override
public void bindView(View v, final Context context, Cursor c) {
final int id = c.getInt(c.getColumnIndex(ItemDb.ID));
final String name = c.getString(c.getColumnIndex(ItemDb.NAME));
}
and the activity class:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] from = new String[] { ItemDb.NAME, ItemDb.CONDITION, ItemDb.EMAIL};
int[] to = new int[] { R.id.etItemName, R.id.etItemCondition, R.id.etEmail };
itemAdapter = new ItemAdapter(this,R.layout.list_item, null, from, to);
this.setListAdapter(itemAdapter);
}
How can I add the button in listview footer?
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" >
<ImageView
android:id="#+id/photo"
android:layout_width="85dp"
android:layout_height="85dp"
android:background="#drawable/photo_frame"
android:contentDescription="#string/imagedescription"
android:src="#drawable/ic_launcher" >
</ImageView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/condition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/name"
android:layout_marginLeft="10dp"
android:text="#string/condition"
android:textColor="#000"
android:textSize="14sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/condition"
android:layout_marginLeft="10dp"
android:text="#string/email"
android:textColor="#000"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
Override getCount() of listview adapter to return data.size()+1 elements;
In getView() insert something like this:
if (position == data.size()){
return getFooterView();
}
In getFooterView() inflate proper layout with button.
I'd like to use my own CursorAdapter class to populate a ListFragment. The cursor is returned from my DB API class. I don't use any ContentProvider.
The cursor is loaded properly, and ListFragment.getListAdapter().getCount() returns number of items from the cursor.
There is just no list showing on the UI ...
This is my ListFragment class:
public class ArticlesListFragment extends ListFragmen
public ArticlesListFragment(int userId, ArticleType type, DBAdapter db) {
ArticlesListFragment.userId = userId;
this.type = type;
this.dbAdapter = db;
Log.d(TAG, "Constructor: type=" + type);
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(true);
mInflater = LayoutInflater.from(getActivity());
cursor = dbAdapter.getArticles(userId, type);
mAdapter = new ListAdapter(getActivity(), cursor, true);
setListAdapter(mAdapter);
//-----> When I call getListAdapter().getCount() here I get a proper number of articles.
}
}
And this is the ListAdapter::
public class ListAdapter extends CursorAdapter {
private Context mContext;
private final LayoutInflater mInflater;
public ListAdapter(Context context, Cursor c, boolean autoRequery) {
super(context, c, autoRequery);
mInflater = LayoutInflater.from(context);
mContext = context;
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
TextView title = (TextView) view.findViewById(R.id.article_title);
title.setText(cursor.getString(cursor
.getColumnIndex(Column._TITLE.name)));
TextView text = (TextView) view.findViewById(R.id.article_text);
text.setText(cursor.getString(cursor
.getColumnIndex(Column._TEXT.name)));
TextView date = (TextView) view.findViewById(R.id.article_date);
date.setText(cursor.getString(cursor
.getColumnIndex(Column._CREATED_DATE.name)));
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final View view = mInflater.inflate(R.layout.articles_list_item,
parent, false);
return view;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (!mDataValid) {
throw new IllegalStateException(
"this should only be called when the cursor is valid");
}
if (!mCursor.moveToPosition(position)) {
throw new IllegalStateException(
"couldn't move cursor to position " + position);
}
View v;
if (convertView == null) {
v = newView(mContext, getCursor(), parent);
} else {
v = convertView;
}
bindView(v, mContext, getCursor());
return v;
}
}
Thank you
EDIT:
public class ArticlesFragment extends Fragment implements OnTabChangeListener {
#Override
public void onAttach(Activity activity) {
super.onAttach(activity);
dbAdapter = new DBAdapter(activity);
dbAdapter.open();
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mRoot = inflater.inflate(R.layout.articles_tabs_fragment, null);
return mRoot;
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setRetainInstance(true);
FragmentManager fm = getFragmentManager();
if (fm.findFragmentByTag(tabId) == null) {
fm.beginTransaction()
.replace(placeholder,
new ArticlesListFragment(userId, ArticleType
.valueOf(tabId), dbAdapter)).commit();
}
}
This is the R.layout.articles_tabs_fragment complete layout file.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" >
<FrameLayout
android:id="#+id/starredArticles"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<FrameLayout
android:id="#+id/newArticles"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<FrameLayout
android:id="#+id/readArticles"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
</LinearLayout>
This is my list item layout. What I notice while debugging is that CursorAdapter's getView() method is never called..
<LinearLayout
android:id="#+id/first_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp" >
<TextView
android:id="#+id/article_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="middle"
android:paddingRight="5dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/article_date"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textSize="10dp" />
</LinearLayout>
<TextView
android:id="#+id/article_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/first_row"
android:layout_span="2"
android:textAppearance="?android:attr/textAppearanceSmall" />