I have a companion configuration app for my watchface, which just presents the various settings as fragments (one for each setting so you can swipe through them quickly)
I would like the fragment views to be scrollable while maintaining the action bar, but what's happening instead is that if you swipe up on the action bar it disappears under the system bar and is very hard to move back.
Sorry if that's unclear, but here are a couple of screen shots.
Here are my various layout and code components; let me know if there's more I need:
AndroidManifest/xml
<?xml version="1.0" encoding="utf-8"?>
<uses-feature android:name="android.hardware.type.watch" android:required="false"/>
<!-- Required to act as a custom watch face. -->
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<!-- So we can keep the screen on and start vibrations -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ref_watch_icon"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".RefWatch"
android:launchMode="singleTop"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name=
"com.pipperpublishing.RefWatch.wearable.watchface.CONFIG_DIGITAL" />
<category android:name=
"com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
My activity's layout XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/appbar_padding_top"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</android.support.v4.view.ViewPager>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:layout_margin="#dimen/fab_margin"
android:src="#android:drawable/ic_media_rew" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/fab_margin"
android:src="#android:drawable/ic_media_ff" />
and most of my OnCreate:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ref_watch);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
...
/*-------------------------------------------------------------*/
/* Set up Settings Pager, Adapter, and floating action buttons */
/*-------------------------------------------------------------*/
...
// Create the adapter that will return a fragment for each of the menu setting sections
mSettingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager());
...
mSettingsViewPager = (ViewPager) findViewById(R.id.container);
...
// Set up the ViewPager with the Settings adapter.
mSettingsViewPager.setAdapter(mSettingsPagerAdapter);
...
This answered my question: https://guides.codepath.com/android/Using-the-App-ToolBar#using-toolbar-as-actionbar as well as some other stackoverflow questions. I added this code:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
params.setScrollFlags(0); // clear all scroll flags
and voila, Action Bar no longer scrolls under the system bar.
Related
I have a recyclerview with cardview for each item. The layout looks fine from Android Studio design. But when it is running on Emulator and inspecting the layout, some of the cardview settings are changed and the layout is different from design page.
Here is the design along with the XML layout file:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="com.example.androidclient.me.ui.SchoolListViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="80dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="80dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:itemCount="20"
tools:listitem="#layout/school_list_item" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
The cardview layout file is:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<com.google.android.material.card.MaterialCardView
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="4dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="12dp"
app:cardBackgroundColor="#color/design_default_color_error"
app:cardCornerRadius="4dp"
app:cardElevation="8dp"
app:contentPadding="8dp"
app:contentPaddingBottom="10dp">
<TextView
android:id="#+id/school_list_item_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
tools:text="school name" />
</com.google.android.material.card.MaterialCardView>
</layout>
Here is what is shown on the emulator along with the layout inspection of cardview:
The dependency section in the app build.gradle is:
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.6.1'
// Retrofit with Moshi Converter
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
implementation 'com.squareup.moshi:moshi-kotlin:1.13.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
// paging
implementation "androidx.paging:paging-runtime:3.1.1"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
My goal is to understand and use the Navigation component in the best way with a complex navigation architecture (I suppose).
To make the global context, I use a main BottomNavigationBar with 5 items. For the management of the fragments associate, I use the example given by Google : https://github.com/googlesamples/android-architecture-components/tree/master/NavigationAdvancedSample.
But my case is a bit more complex than just a bottom bar. In one of the destinations from one of the fragments launched by the bottom bar, I have another RecyclerView menu and a fragment container to navigate between fragments. I put here the important part of my primary graph :
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main"
app:startDestination="#id/mainFragment">
<fragment
android:id="#+id/mainFragment"
android:name="com.exemple.fragment.MainFragment"
android:label="#string/main_label"
tools:layout="#layout/mainFragment">
<action
android:id="#+id/action_mainFragment_to_goScreen"
app:destination="#id/goScreen">
</action>
</fragment>
<fragment
android:id="#+id/goScreen"
android:name="com.exemple.fragment.GoFragment"
android:label="#string/goLabel"
tools:layout="#layout/fragment_go">
<action
android:id="#+id/action_goScreen_to_mainFragment"
app:destination="#id/mainFragment" />
<argument
android:name="arg1"
app:argType="com.exemple.customType"
android:defaultValue="#null"
app:nullable="true" />
<argument
android:name="arg2"
app:argType="string"
android:defaultValue="#null"
app:nullable="true" />
</fragment>
</navigation>
And the xml with the bottom bar which starts this graph :
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.exemple.MainActivity">
<RelativeLayout
android:id="#+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="#+id/fake_toolbar"
android:layout_width="0dp"
android:layout_height="0dp"/>
<androidx.fragment.app.FragmentTabHost
android:id="#+id/main_host_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_navigation" />
<!-- navigation bottom -->
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_alignParentBottom="true"
android:background="#color/navigationBarColor"
app:itemIconTint="#color/textColorNavigationBar"
app:itemTextColor="#color/textColorNavigationBar"
app:menu="#menu/menu_bottom_navigation" />
</RelativeLayout>
</layout>
And here is an example of the graph corresponding to the go fragment (the destination ):
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/go"
app:startDestination="#id/firstGoFragment">
<action android:id="#+id/action_to_firstGoFragment"
app:destination="#id/firstGoFragment"/>
<fragment
android:id="#+id/firstGoFragment"
android:name="com.exemple.go.firstGoFragment"
android:label="#string/firstGoFragmentLabel"
tools:layout="#layout/firstGoFragment" >
</fragment>
<action android:id="#+id/action_to_secondFragment"
app:destination="#id/secondFragment"/>
<fragment
android:id="#+id/secondFragment"
android:name="com.exemple.go.SecondFragment"
android:label="#string/secondFragmentLabel"
tools:layout="#layout/secondFragment" >
</fragment>
</navigation>
The associate xml is :
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorGreyLight"
android:clickable="true"
android:focusable="true">
<RelativeLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/quit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:paddingBottom="15dp"
android:paddingEnd="15dp"
android:paddingTop="15dp"
app:srcCompat="#drawable/ic_quit_white" />
<com.teedji.mobeelity.custom.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/go"
android:textColor="#color/colorWhite"
android:textSize="17sp"
android:textStyle="bold" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/goMenu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:overScrollMode="never"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout3" />
<!-- include fragment child container -->
<fragment
android:id="#+id/go_nav_host_fragment_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/goMenu"
app:navGraph="#navigation/go"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Now, to navigate to the go screen I simply use
findNavController().navigate(MainFragmentDirections.actionMainFragmentToGoScreen(arg1, arg2))
or
findNavController().navigate(R.id. action_mainFragment_to_goScreen)
But when I am on the Go fragment, the navController the I find using findNavController() is still the mainFragment one. So the navigate() fonction didn't find the action id. To solve it, I had to change the navHost programaticaly in the GoFragment like this :
override fun onCreate(savedInstanceState: Bundle?) {
Log.i(LOG_TAG, "onCreate")
super.onCreate(savedInstanceState)
if( fragmentManager != null ) {
// If the Nav Host fragment exists, return it
val existingFragment = fragmentManager!!.findFragmentByTag(FRAGMENT_TAG) as NavHostFragment?
existingFragment?.let { navHostGoFragment = it }
// Otherwise, create it and return it.
if ( navHostGoFragment == null) {
navHostGoFragment = NavHostFragment.create(R.navigation.go)
fragmentManager!!.beginTransaction()
.add(R.id.go_nav_host_fragment_container, navHostGoFragment!!, FRAGMENT_TAG)
.commit()
}
}else {
Log.e(LOG_TAG, "fragmentManager is null so I can't find the fragment host")
}
}
and then use navHostGoFragment!!.navController.navigate(R.id.action_to_firstGoFragment) to navigate in the new container
But doing like this, my firstFragment is created twice (I can see it on my logs) and that generate some problems like Cannot add the same observer with different lifecycles for example ( I solve this with adding
if (model.getLiveData().hasObservers()) {
model.getLiveData().removeObserver(observer)
}
before
model.getLiveData().observe(viewLifecycleOwner, observer)
)
But I think I am not doing the Navigation part like I should...
Could you provide any help to make this work more efficiently with stability ?
Try to use go_nav_host_fragment_container.findNavController().navigate(), if you are using Kotlin Android Extensions or findViewById(R.id.go_nav_host_fragment_container).findNavController().navigate(), and see if it works.
This has been the biggest headache for me. I've been following the tutorial at
https://developers.google.com/maps/documentation/android-api/start?hl=en
but I always get a
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class fragment
ONLY on api 23. This is the most confusing part. Other APIs over 18 work fine.
I believe I've covered all the basic components,
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
My google play version is up to date.(8487000)
I've tried placing the map fragment everywhere. Nothing seems to work.
activity_maps.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/maps"
class ="com.google.android.gms.maps.SupportMapFragment" />
MapsActivity:
package com.example.michael.myapplication;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends android.support.v4.app.FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.maps);
mapFragment.getMapAsync(this);
}
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney, Australia, and move the camera.
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
For anyone stumbling on this:
Reinstall your emulator. Seriously. That fixed it for me.
If you are testing on emulator, try removing and creating AVD again. I was also facing that issue and that fixed for me.
I am following the steps in google but can't see my map in fragment. bellow is the code. if guys please help me?
I already added google-play-services_lib with my project. testing in real device. using Google APIs
Mainfest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mymaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="com.example.mymap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.example.mymap.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mymaps.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY KEY" />
<uses-library
android:name="com.google.android.maps"
android:required="true" />
</application>
</manifest>
UI 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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<fragment
android:id="#+id/the_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"
/>
</RelativeLayout>
MainActivity:
package com.example.mymaps;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
setContentView(R.layout.activity_main);
} catch (Exception e) {
System.out.print(e);
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Put these lines on the AndroidManifest.xml file after the meta-data tag::
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Google has made it mandatory for android phones to have the google play services installed in order to use the map. So the tag checks for google play services is installed on the phone or not. If no, then it automatically redirects the user to google play site to get the required software installed..
If the problem still exists, then use this tutorial by Ravi Tamada and do not forget to add the lines mentioned in this answer.
http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/
dec variable as global private GoogleMap googleMap;
extends FragmentActivity not Activity
after setContentView add this code
FragmentManager fragmentManager = getSupportFragmentManager();
SupportMapFragment mapFragment = (SupportMapFragment) fragmentManager
.findFragmentById(R.id.map);
googleMap = mapFragment.getMap();
googleMap.getUiSettings().setCompassEnabled(true);
googleMap.getUiSettings().setZoomControlsEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.getUiSettings().setRotateGesturesEnabled(true);
in xml
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment" />
if you generate the googleMap api key with currect pakage name this will work
ON SUNDAY I ACTUALLY SIDE-LOADED MY FIRST APP!!! Simple, unfinished, couple bugs, but it works.
My opening screen (XML: "event_list.xml") is a scroll list - select one get detail screen.
XML looks like: (This code is still a fragment.)
<?xml version="1.0" encoding="utf-8"?>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.dummies.android.taskreminder.EventListFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
And the row (XML "event_row.xml") looks like:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/text1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="12dp"
android:padding="2dip" />
I want a couple buttons at the top above the scroll. The best I can do is:
<?xml version="1.0" encoding="utf-8"?>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.dummies.android.taskreminder.EventListFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="#+id/btn_Add"
android:text="#string/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</fragment>
But the button overlays the first entry!
What ties the row to the list screen and how do I get two buttons above the scroll (rows)?
This is what finally worked.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:id="#+id/btn_Add"
android:layout_width="50dp"
android:layout_height="30dp"
android:textSize="12dp"
android:padding="1dip"
android:text="#string/add" />
<Button android:id="#+id/btn_Exit"
android:layout_width="50dp"
android:layout_height="30dp"
android:textSize="12dp"
android:padding="1dip"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/btn_Add"
android:text="#string/exit" />
<Button android:id="#+id/btn_Other"
android:layout_width="50dp"
android:layout_height="30dp"
android:textSize="12dp"
android:padding="1dip"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/btn_Exit"
android:text="#string/other" />
<fragment
android:name="com.dummies.android.taskreminder.EventListFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_Add" />
</RelativeLayout>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/text1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="12dp"
android:padding="2dip" />
<!-- This defines a row in which text can be placed -->
<!-- "text1" is the IDof the view for loading the list with data -->
Now just need to make the button code copied from detail screen (activity only) work in list screen (w/ fragment):
This generates errors: (findViewById undefined)
mExitButton = (Button)findViewById(R.id.btn_Exit);
This crashed:
mExitButton = (Button)getView().findViewById(R.id.btn_Exit);
Still working in this (it's late):
View myFragmentView = inflater.inflate(R.layout.????????, container, false);