I'm trying to add an Horizontal Progress bar to my view like so:
res/menu.xml
<item android:id="#+id/menuItemProgress"
android:title="Progress"
android:actionLayout="#layout/component_cancellable_progressbar"
android:showAsAction="always"/>
component_cancellable_progressbar.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/searchProgressWrapper"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<ProgressBar android:id="#+id/searchProgress"
android:layout_height="30dp"
android:layout_width="150dp"
style="#style/Custom.Widget.ProgressBar.Horizontal"
android:max="100" />
<ImageView android:id="#+id/cancelSearch"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingRight="8dp"
android:layout_gravity="right|center_vertical"
android:src="#android:drawable/ic_notification_clear_all"
android:scaleType="fitXY" />
</FrameLayout>
How do I access this ProgressBar from within an Action (To make it Visisble / Invisible / Progress) ?
it is possible to get the view of the action item.
however, do note that sometimes action items get to be inside the overflow menu so you might get a null instead.
so, how can you do it?
here's a sample code:
public boolean onCreateOptionsMenu(final Menu menu) {
getSupportMenuInflater().inflate(R.menu.main, menu);
new Handler().post(new Runnable() {
#Override
public void run() {
final View syncItemView = findViewById(R.id.action_search);
...
this was tested when using actionBarSherlock library, on android 4.1.2 and android 2.3.5 .
another alternative is to use a more extensive way , used on the showcaseView library, here .
onCreate() and after you can simply access it via findViewById() like normal. Problem was caused by something else.
You can override onCreateOptionsMenu and catch your view there:
#Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.getItem(0).getActionView();
...
or by searching the id
View v = (View) menu.findItem(R.id.search).getActionView();
I inserted a custom drop down menu in the action bar and was able to gain control of it this way.
Following is a very helpful link for actionBar.Hope you will able to implement what you want.
http://thiranjith.wordpress.com/2011/07/15/actionbar-design-pattern-example-for-android/
public class ActionBar extends FrameLayout {
private ProgressBar mProgress;
public ActionBar(Context context, AttributeSet attrs) {
super(context, attrs);
mInflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
FrameLayout barView = (RelativeLayout) mInflater.inflate(R.layout.actionbar, null);
addView(barView);
mProgress = (ProgressBar) barView.findViewById(R.id.actionbar_progress);
public void showProgressBar() { ... }
public void hideProgressBar() { ... }
public boolean isProgressBarVisible() { ... }
}
Then from your activity control your progressbar like following.
public class MainActivity extends Activity {
private ActionBar mActionBar;
#Override
public void onCreate(Bundle savedInstanceState) {
mActionBar = (ActionBar) findViewById(R.id.actionBar);
mActionBar.showProgressbar()
}
}
Related
I try to set up a MenuItem with an actionView as described here.
In my case the ActionView Widget is a SeekBar.
The problem is, that when the ActionView is shown on icon click, its width is way smaller than expected as you can see in the following screenshots:
The docs say:
If the widget is on the app bar, the app should display the widget as
an icon. If the widget is in the overflow menu, the app should display
the widget as a menu item. When the user interacts with the action
view, it expands to fill the app bar.
In my case, nothing gets "expanded". Instead of taking up the whole width of the ActionBar, its tiny.
To fix it I tried using another View like an EditText, but got similar Results. (The EditText is small on start, but expands on writing in it).
It seems to work with a android.support.v7.widget.SearchView as used in the docs.
I also tried it with Theme.AppCompat.Light.DarkActionBar or Theme.AppCompat.Light.NoActionBar providing a Toolbar in the layout without any noticeable difference.
Here is the code I used:
MainActivity
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/* set this on other layout with toolbar in it
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
*/
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.camera_menu, menu);
return true;
}
}
app_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/action_item"
android:title="Action"
android:icon="#drawable/ic_icon_in_black_24dp"
app:showAsAction="ifRoom|collapseActionView"
app:actionViewClass="android.widget.SeekBar"
/>
</menu>
I also tried app:actionViewLayout=#layout/seekbar_layout instead of actionViewClass
where seekbarLayout was something like this
<?xml version="1.0" encoding="utf-8"?>
<SeekBar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/action_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
Where I also tried different versions of ViewGroups around it like Linear, Relative or FrameLayouts, or tried to set a fixed width of my SeekBar without any success.
What Am I missing or doing wrong here?
Adding Seekbar as the menu item, will take up the size of default menu item.
If you need Seekbar to extend across the appbar, then you can create your own Toolbar and add SeekBar like this.
<youtLayoutRoot>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:titleTextColor="#color/white" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="10"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<!-- your content layout here -->
</youtLayoutRoot>
Make the theme of your activity as Theme.AppCompat.Light.NoActionBar and run the application. You should be able to see the seekbar spanning across the toolbar.
In your activity just inflate the menu and it will take ut its size.
It works for me and hope that seekbar with menu item will also work for you.
toolbar.inflateMenu(R.menu.menu_delete)
toolbar.setNavigationIcon(R.drawable.vector_back)
toolbar.setNavigationOnClickListener {
onBackPressed()
}
toolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.delete -> {
deleteCall()
true
}
else -> {
false
}
}
}
The "magic" takes place in Toolbar.expandItemActionView. This method overrides the layout parameters of the expanded ActionView and sets the width to wrap_content. Now to one possible solution:
Toolbar.expandItemActionView checks if the ActionView implements CollapsibleActionView interface and calls CollapsibleActionView.onActionViewExpanded method if this is the case. This is your chance to fix the layout paramters and set the width to match_parent. Derive a custom class from the SeekBar and let it implement CollapsibleActionView:
public class CollapsibleSeekBar extends AppCompatSeekBar implements CollapsibleActionView {
public CollapsibleSeekBar(Context context) {
super(context);
}
public CollapsibleSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CollapsibleSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
#Override
public void onActionViewExpanded() {
ViewGroup.LayoutParams params = getLayoutParams();
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
setLayoutParams(params);
requestLayout();
}
#Override
public void onActionViewCollapsed() {
}
}
Use it in your menu item via app:actionViewClass.
Also make sure to use the appropriate CollapsibleActionView.
If you are using android.support.v4.widget.Toolbar you also need android.support.v7.view.CollapsibleActionView.
If you have an android.widget.Toolbar use android.view.CollapsibleActionView
I have an overflow button inside a CardView in Recyclerview. Whenever I am clicking the button,I show a popup menu but also RecyclerView is scrolling down one item. Can anyone please help me stop this unwanted scrolling?
Basically I am trying to replicate the same overflow button behavior as in Playstore.
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp">
<android.support.v7.widget.CardView
android:id="#+id/cv_tracks"
android:layout_width="match_parent"
android:layout_height="65dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<ImageView
android:id="#+id/ivTracks"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="#drawable/unknown"
/>
<Button
android:id="#+id/imgbtn_overflow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:drawableTop="#drawable/ic_overflow"
android:paddingLeft="25dp"
android:paddingRight="20dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
Adapter:
#Override
public void onBindViewHolder(final TracksViewHolder tracksViewHolder, int i) {
tracksViewHolder.imgBtnOverflow.setTag(i);
tracksViewHolder.imgBtnOverflow.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//Creating the instance of PopupMenu
final int position = (Integer) v.getTag();
PopupMenu popup = new PopupMenu(mContext,tracksViewHolder.imgBtnOverflow);
//Inflating the Popup using xml file
popup.getMenuInflater()
.inflate(R.menu.popup_menu_overflow, popup.getMenu());
//registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
if(mPopUpClick!=null)
mPopUpClick.actionOnPopUpItemClick(position,item,songs.get(position));
return true;
}
});
popup.show(); //showing popup menu
}
});
}
UPDATE:
Got the issue .When the popup menu displays,it slides the list down so as to display the whole dropdown. How to adjust popup to display up/down depending on the space available?
Tried using android.widget.PopupMenu instead of android.support.v7.widget.PopupMenu and Voila, it works. So is it a bug in Support library. Can great developers out here confirm the same?
You can have your AnchorView override requestRectangleOnScreen() and return false. This will prevent any parent ScrollView from scrolling.
So, in your case, imgBtnOverflow would be a custom ImageButton, like so:
/**
* A custom {#link ImageButton} which prevents parent ScrollView scrolling when used as the
* anchor for a {#link android.support.v7.widget.PopupMenu}
*/
public class NonScrollImageButton extends ImageButton {
public NonScrollImageButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
#Override
public boolean requestRectangleOnScreen(Rect rectangle, boolean immediate) {
return false;
}
}
Props to jankovd (https://gist.github.com/jankovd/19ef35efd1f00e9213fa)
An issue has been filed against the Support PopupMenu here:
https://code.google.com/p/android/issues/detail?id=135439
I have same problem, and I use this way:
mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false) {
#Override
public boolean requestChildRectangleOnScreen(RecyclerView parent, View child, Rect rect, boolean immediate) {
return false;
}
};
mRecyclerView.setLayoutManager(mLayoutManager);
RecyclerView user layoutmanager to manage layout, so I think change layoutmanger behaver is the bettor solution.
requestRectangleOnScreennot work for me, in my case, requestRectangleOnScreennot called, when show popupMenu.
my solution is override requestChildRectangleOnScreen, and reture false, work well.
public class PopupAncorRecyclerViewPager extends RecyclerView {
#Override
public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate) {
return false;
}
}
I have implemented a custom action bar layout with AppCompat:
public class DoneBarActivity {
public interface OnSaveActionListener {
public void onSave();
}
public static void setupActionBar(final ActionBarActivity activity,
final OnSaveActionListener listener) {
// Inflate a "Done/Cancel" custom action bar view.
final LayoutInflater inflater = (LayoutInflater) activity
.getSupportActionBar().getThemedContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater.inflate(
R.layout.actionbar_custom_view_done_cancel, null);
customActionBarView.findViewById(R.id.actionbar_done)
.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// "Done" (or "Save")
if (listener != null) {
listener.onSave();
}
activity.finish();
}
});
customActionBarView.findViewById(R.id.actionbar_cancel)
.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// "Cancel"
activity.finish();
}
});
// Show the custom action bar view and
// hide the normal Home icon and title.
final ActionBar actionBar = activity.getSupportActionBar();
actionBar.setDisplayOptions(
ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM |
ActionBar.DISPLAY_SHOW_HOME |
ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setCustomView(customActionBarView,
new ActionBar.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
);
}
}
My activity is just a dumb ActionBarActivity that loads a fragment in a FrameLayout. Here's the fragment code:
#Override
public View onCreateView(final LayoutInflater inflater,
final ViewGroup container,
final Bundle savedInstanceState) {
// ...
DoneBarActivity.setupActionBar((ActionBarActivity) getActivity(),
new DoneBarActivity.OnSaveActionListener() {
#Override
public void onSave() {
saveIssueChangesAndClose();
}
});
return v;
}
Here's the action bar layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:divider="?attr/dividerVertical"
android:showDividers="middle"
android:dividerPadding="12dp">
<include layout="#layout/include_cancel_button"/>
<include layout="#layout/include_done_button"/>
</LinearLayout>
Here are the two buttons:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?actionButtonStyle"
android:id="#+id/actionbar_cancel"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
style="?actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:drawableLeft="#drawable/ic_action_cancel"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:text="#android:string/cancel"/>
</FrameLayout>
and
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?actionButtonStyle"
android:id="#+id/actionbar_done"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
style="?actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingRight="20dp"
android:drawableLeft="#drawable/ic_action_done"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:text="#string/save"/>
</FrameLayout>
Here's the result in Jelly Bean vs. Gingerbread (Galaxy Nexus for the first, emulator for the latter):
Sorry for the quality, the animated PNG didn't work properly so I switched to animated GIF.
As you can see, the content layout is going over the action bar custom layout (notice the blue overflow in JB and scrollbar position).
Using a non-custom action bar layout works properly on both JB and GB.
The overlay is caused due the different resource id used to reference the content view in different versions of Android. Please refer to the post of Shellom for detailed information. Meanwhile, the following snippet should help you to identify the relevant portion of your code.
// http://code.google.com/p/android/issues/detail?id=58108
private static int getContentViewCompat() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH ?
android.R.id.content : R.id.action_bar_activity_content;
}
Update: The switch is no longer needed. You can update appcompat-v7 to revision 19.0.0. or newer and then reference android.R.id.content on all Android versions.
I'm new to Android programming and probably I don;t understand Java very well yet, so i got this problem with my program.
Every time I press button on my menu I get the java.lang.NullPointerException.
Is there any way to reference to this TextView object and change its text when item2 on menu is clicked?
public class MainActivity extends Activity {
TextView tv;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MainActivity.this.tv = (TextView) findViewById(R.id.tekst1);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.mymenu, menu);
return super.onCreateOptionsMenu(menu);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.item2) {
MainActivity.this.tv.setText("aaa");
}
return super.onOptionsItemSelected(item);
}
}
EDIT:
mymenu xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/item1"
android:icon="#android:drawable/ic_menu_week"
android:title="Option 1"/>
<item
android:id="#+id/item2"
android:icon="#android:drawable/ic_menu_month"
android:title="Option 2"/>
</menu>
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" >
<TextView
android:id="#+id/tekst1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
You need to load the layout BEFORE retrieving the element.
Just replace
MainActivity.this.tv = (TextView) findViewById(R.id.tekst1);
setContentView(R.layout.activity_main);
By
setContentView(R.layout.activity_main);
MainActivity.this.tv = (TextView) findViewById(R.id.tekst1);
The findViewById method tries to find an element (from an ID) inside the hierarchy of the view. That's why you need to load this hierarchy (from the XML file) before! Otherwise you search in an empty hierarchy of views
You have to change your onCreate method to this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MainActivity.this.tv = (TextView) findViewById(R.id.tekst1);
}
You have to reference your views after doing setContentView for your Activty.
By using the setContentView(int layoutResId) method android platform is creating all the view objects contained in your layout xml file provided to the setContentView(int layoutResId) method. This means that before the setContentView(int layoutResId) method is called the findViewById(int resId) method will return null for any view references in the layout, causing some potential NullpointerExceptions. To avoid these errors it's a good habit to place the setContentView(int layoutResId) method call at the very top of the onCreate() method.
Check this out : http://www.jayway.com/2009/03/26/layout-resources-in-android/
I'm currently using a ListFragment together with an ExpandableListView to show some data backed by a SimpleCursorTreeAdapter. Everything works fine, but I recently switched to the support.v4 package, to make use of the ViewPager class to swipe between tabs. Swiping and all the other classes that now use the support.v4.Fragment work fine, but my ListFragment has stopped working.
There are no exceptions thrown, but the ListFragment simply doesn't show any items.
This is the code for the ListFragment:
public class VisuTextFragment extends ListFragment {
private Storage mStorage;
private int mFilterSensortype;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mStorage = Storage.newSQLiteDatabase(getActivity());
mFilterSensortype = -1;
setHasOptionsMenu(true);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.l_visu_text, container, false);
}
#Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
fillData();
}
#Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.textvis, menu);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_filter:
final Dialog dialog = new Dialog(getActivity());
dialog.setTitle("Filter by sensor type");
dialog.setContentView(R.layout.l_dialog_filter);
Button ok = (Button) dialog.findViewById(R.id.filter_ok);
ok.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
int filter = Integer.parseInt(((EditText) dialog.findViewById(R.id.et_filter)).getText().toString());
mFilterSensortype = filter;
fillData();
dialog.dismiss();
}
});
Button cancel = (Button) dialog.findViewById(R.id.filter_cancel);
cancel.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
dialog.cancel();
}
});
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
dialog.show();
break;
}
return true;
}
#Override
public void onResume() {
super.onResume();
fillData();
}
public void fillData() {
Log.d("VisuTextFragment", "fillData()");
Cursor cursor;
if (mFilterSensortype == -1)
cursor = mStorage.queryAllAsCursor();
else
cursor = mStorage.query(mFilterSensortype);
TextVisCursorAdapter adapter = new TextVisCursorAdapter(
getActivity(),
cursor,
R.layout.l_visu_text_group,
new String[] { Storage.ELEMENT_ID, Storage.ELEMENT_ENTRIES_DATE, Storage.ELEMENT_ENTRIES_LATITUDE, Storage.ELEMENT_ENTRIES_LONGITUDE, Storage.ELEMENT_ENTRIES_SENSORTYPE },
new int[] { R.id.id, R.id.date, R.id.latitude, R.id.longitude, R.id.sensortype },
R.layout.l_visu_text_child,
new String[] { Storage.ELEMENT_MEASUREMENTS_VALUE },
new int[] { R.id.value });
ListView lv = (ListView) getListView();
ExpandableListView elv = (ExpandableListView) lv;
elv.setGroupIndicator(null);
elv.setAdapter(adapter);
}
}
And this is the layout that I'm using (don't know if that helps):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/id"/>
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/date"/>
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/latitude"/>
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/longitude"/>
<TextView
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/sensortype"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ExpandableListView android:id="#+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:transcriptMode="normal"/>
<TextView android:id="#+id/android:empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/no_entries"/>
</LinearLayout>
</LinearLayout>
Just FYI: The TextView's in the layout file are shown, but the list itself is just missing. Not even the TextView for an empty list is shown.
Hope you can help.
EDIT: I have checked for the ExpandableListView's width and height via their corresponding methods and both return a value of 0. Its getCount() method returns 347. So the View definitely exists and is filled properly, but it is for some weird reason just not drawn to the screen.
EDIT2: Ok I fixed the problem. The problem was that the LinearLayout that hosted the TextViews on top of the actual list had its layout_height attribute set to fill_parent, which strangely was no issue for the non-support version as well as the composer in eclipse, since they both worked that way and I didn't even notice that it was set to fill_parent.
getListView() in a ListFragment is specifically looking for a listview id of #id/android:list. I'm not sure that adding the "+" in there like you did would have an effect or not, but it's the first thing I would try.
You also note you switched to the support library... did you switch all the appropriate method calls? For example, instead of getFragmentManager you would need to use getSupportFragmentManager and instead of using an Activity to control the fragments, you would need to use FragmentActivity, etc.
I think that that its butter to use android:id="#android:id/list" instead of android:id="#+id/android:list", also, in your case its really useless to extend ListFragment, just use Fragment and use findViewById for your expandableList.
Can you change:
#Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
to:
public void onActivityCreated(Bundle aSavedInstanceState) {
super.onActivityCreated(aSavedInstanceState);
fillData();
}
make sure that your fillData method is called.
Ok I fixed the problem. The problem was that the LinearLayout that hosted the TextViews on top of the actual list had its layout_height attribute set to fill_parent, which strangely was no issue for the non-support version as well as the composer in eclipse, since they both worked that way and I didn't even notice that it was set to fill_parent.