I keep getting an error message when running my app? - android

This is the error message I keep getting when I run my app in the emulator.
There's nothing in the Error Log and it doesn't really tell me where the error is coming from but I get this in the LogCat:
WARN/ActivityManager(51): Launch timeout has expired, giving up wake lock!
WARN/ActivityManager(51): Activity idle timeout for HistoryRecord{44e0fb68 com.gamer.network2/.FirstActivity}
WARN/InputManagerService(51): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#44e98158
ERROR/gralloc(51): [unregister] handle 0x494d08 still locked (state=40000001)
This is my Java for the Layout that comes up when the app is started: (I would think if this is what comes up first, that would be where the problem is, but I really don't know.)
package com.gamer.network2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class FirstActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView next1 = (TextView) findViewById(R.id.signuptext);
next1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Screen2.class);
startActivityForResult(myIntent, 0);
finish();
}
});
}
}
Here's my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gamer.network2"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="#drawable/newlogo2"
android:label="#string/app_name">
<activity android:name=".FirstActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Screen2"></activity>
<activity android:name=".Screen3"></activity>
<activity android:name=".Screen4"></activity>
<activity android:name=".MyOnItemSelectedListener"></activity>
</application>
</manifest>
And the XML code for the layout/main:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background"
android:weightSum="1"
>
<ImageView android:src="#drawable/newlogo2"
android:id="#+id/imageView1"
android:layout_gravity="center"
android:layout_marginTop="30dip"
android:layout_height="112dp"
android:layout_weight="0.11"
android:layout_width="135dp"></ImageView>
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/textView2"
android:text="Sign in to GameNet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dip"></TextView>
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/textView3"
android:text="Username:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dip"
android:layout_marginTop="15dip"></TextView>
<EditText android:id="#+id/EnterUsername"
android:layout_height="wrap_content"
android:layout_width="190dp"
android:layout_gravity="center">
<requestFocus></requestFocus>
</EditText>
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/textView4"
android:text="Password: "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dip"
android:layout_marginTop="10dip"></TextView>
<EditText
android:id="#+id/EnterPassword"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:layout_gravity="center"
android:layout_width="190dp"></EditText>
<Button android:text="Sign in"
android:id="#+id/button1"
android:layout_width="121dp"
android:layout_gravity="center"
android:layout_height="wrap_content"></Button>
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/signuptext"
android:text="Not a member? Sign up now!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dip"></TextView>
</LinearLayout>
I can post whatever other code you need to help me. =]
Thanks

i think onClickListener is for buttons only, not textviews

Related

Android: Keyboard does not always appear on edittext focus

I have a Login view. When the user starts the app, if he already synced with the server before, the app opens on the login view and the user is prompted to enter his login. In this situation, the keyboard opens automatically when the app starts. If, however, the user never synced before, the user is redirected to the configuration view and will sync from there. After the sync is over, the configuration activity finishes and the user then sees the login view for the first time. At this moment, the focus is on the PIN edit text, as it should, but the keyboard does not open.
I tried several solutions found online, none of which worked. This is my code in its current state:
View:
#Override
public void onResume() {
super.onResume();
EditText pinEditText = (EditText)findViewById(R.id.passwordEditText);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
boolean dbContainsUsers = controller.Dispatcher.Count(new controller.User(), false) > 0;
if (!dbContainsUsers) {
Intent i = new Intent(getApplicationContext(), Configuration.class);
startActivity(i);
}
pinEditText.clearFocus();
pinEditText.requestFocus();
imm.showSoftInput(pinEditText, InputMethodManager.SHOW_IMPLICIT);
}
Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="view.Login">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<include layout="#layout/app_bar" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="vertical">
<EditText
android:id="#+id/passwordEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/lgnEditTextMarginLeft"
android:textSize="#dimen/textSizeL"
android:ems="8"
android:inputType="numberPassword"
android:selectAllOnFocus="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="horizontal">
<Button
android:id="#+id/btnSynchroniser"
style="#style/RexforetTheme.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/btn_marge_top"
android:drawableLeft="#drawable/icon_sync"
android:textSize="#dimen/textSizeM"
android:text="#string/btn_synchroniser" />
<Button
android:id="#+id/btnConfiguration"
style="#style/RexforetTheme.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/btn_marge_top"
android:drawableLeft="#drawable/icon_configuration"
android:textSize="#dimen/textSizeM"
android:text="#string/btn_configuration" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ca.aaa.bbb">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/RexforetTheme">
<activity android:name="view.Login">
<intent-filter>
<action android:name="android.intent.action.MAIN"
android:windowSoftInputMode="stateVisible"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="view.MenuPrincipal" />
<activity android:name="view.Configuration" />
<service
android:name="service.WebDBService"
android:exported="false"/>
</application>
</manifest>
you have android:windowSoftInputMode="stateVisible" in this place replace
android:windowSoftInputMode="stateHidden|adjustPan"
in your menifest file
you have android:windowSoftInputMode="stateVisible" in this place replace
android:windowSoftInputMode="adjustResize"
in your manifest file.

onClick method keeps telling me "Unfortunately,myapp has stopped"

I am using a startActivityForResult method to get a string from an activity,the activity has an editview and a button to return the inputted value of the editview,but when i click on the button,it keeps telling me "Unfortunately,myapp has stopped",dont know where the problem is coming from?
This is the line calling the activity
startActivityForResult(new Intent("com.dreama.trafic.SearchActivity"),request_Code);
and this is the xml file for the activity
<?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" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editSearch"
android:layout_centerHorizontal="true"
android:layout_marginBottom="60dp"
android:text="#string/searchLocation"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#f00" />
<EditText
android:id="#+id/editSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:ems="10" />
<Button
android:id="#+id/searchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:onClick="click"
android:text="#string/search" />
</RelativeLayout>
and this is the click method
public void click(View view) {
Intent data = new Intent();
EditText editSearch = (EditText) findViewById(R.id.editSearch);
data.setData(Uri.parse(editSearch.getText().toString()));
setResult(RESULT_OK, data);
finish();
}
Try this..
I guess you are getting ActivityNotFoundException
Change this..
startActivityForResult(new Intent("com.dreama.trafic.SearchActivity"),request_Code);
to
startActivityForResult(new Intent(currentActivity.this,SearchActivity.class),request_Code);
it also may be because you have not declared SearchActivity.java in your manifest file as
<activity android:name=".SearchActivity"/>

Android: opening activity from widget as dialog and disabling the background

I am working on widget project and when I touch the widget a new activity that is styled like a dialog box. The main activity opens and the dialog styled activity appears and when I touch the main activity the dialog styled activity disappears.
1) Is there a way to disable the activity? or
2) Is there away to open the dialog styled activity without opening the activity?
Here is my onReceive Class in my BroadcastReceiver
public void onReceive(Context context, Intent intent)
{
Log.i(TAG,"In onReceive");
if(intent.getAction().equals(INTENT_ACTION))
{
Intent mIntent = new Intent(context,sendActivity.class);
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(mIntent);
}
}
Dialog Styled Actvity
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp" />
<TextView
android:id="#+id/tvdialogTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:layout_toRightOf="#+id/image"/>
<TextView
android:id="#+id/tvStatus01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF" />
<TextView
android:id="#+id/tvStatus02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"/>
<Button
android:id="#+id/btnWidgetDialogCancel"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_below="#+id/image"
/>
</RelativeLayout>
Part of my Manifest
<activity
android:name="com.example.widget.sendActivity"
android:theme="#android:style/Theme.Dialog"
android:excludeFromRecents="true">
</activity>
Thanks in advance.
I used this line if anyone else is interested
this.setFinishOnTouchOutside(false);

Continuation of 'app not working in Droid' investigation: the code. Can anyone see any obvious error here?

In my previous question I asked if System.currentTimeMillis() was buggy in Droid, and the answer was no.
I assume the problem I'm having is somewhere else. While I wait for my Droid lone-user to report if a test app works on his phone, I would like to post some relevant code here.
Please keep in mind that I removed everything in the code I thought would be irrelevant (posting the code leading to the first suspicious line in the log). I might have removed the code where the problem is, but I doubt it. It smells like a layout, not code, problem. I say this because (see last line, where the log is) the surface is 0.
Best regards, Ari.
MANIFEST
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".BeMeBB" android:label="#string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="BeMeBBPref" android:label="#string/app_name">
</activity>
</application>
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" />
<supports-screens>
</supports-screens>
LAYOUT
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="0pt" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="bottom" android:background="#00000001">
<android.view.SurfaceView android:id="#+id/preview_LAND"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:keepScreenOn="true" android:layout_margin="0pt">
</android.view.SurfaceView>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_weight="1">
<TextView android:id="#+id/ACCELERATION_LINE" android:text="0 2 4 6 8 10 12 14 16 18 20 "
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:typeface="monospace" android:layout_weight="0"
android:textSize="20dp" android:textStyle="bold" android:textColor="#color/white"
android:layout_gravity="center_horizontal" android:paddingTop="0dp"
android:paddingLeft="0dp" android:background="#66000000" />
<TextView android:id="#+id/ACCELERATION" android:text="#string/Accelerometers"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:typeface="monospace" android:textStyle="bold"
android:layout_weight="0" android:textSize="20dp" android:textColor="#color/white"
android:layout_gravity="center_horizontal|top" android:paddingLeft="0dp"
android:background="#66000000" />
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:gravity="bottom" android:layout_weight="1">
<Button android:id="#+id/SAVE_LAND" android:text="#string/Save"
android:layout_width="wrap_content" android:gravity="left|bottom"
android:layout_height="wrap_content" android:layout_weight="0"
android:textSize="26dp" android:textColor="#color/black"
android:padding="20dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
CODE
public class BeMeBB extends Activity implements OnClickListener, android.content.DialogInterface.OnClickListener, SensorEventListener {
private SurfaceView preview=null;
private SurfaceHolder previewHolder=null;
SurfaceHolder.Callback surfaceCallback = new SurfaceHolder.Callback() {
public void surfaceCreated(SurfaceHolder holder) {
DoRecording();
}
}; // End SurfaceHolder.Callback surfaceCallback
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main_land);
preview=(SurfaceView)findViewById(R.id.preview_LAND);
previewHolder=preview.getHolder();
previewHolder.addCallback(surfaceCallback);
previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
} // End OnCreate
private void DoRecording() {
m_worker.setSurfaceHolder(previewHolder);
} // End DoRecording
} // End class
IN ANOTHER CLASS
public void setSurfaceHolder(SurfaceHolder previewHolder) {
m_previewHolder = previewHolder;
m_surface = m_previewHolder.getSurface();
Log.d("BeMeBB", "BeMeBBWorker m_surface=" + m_surface);
} //End setSurfaceHolder
AND THE RESULT IN LOG (SURFACE IS NOT VALID):
11-19 17:58:13.171 D/BeMeBB ( 1404): BeMeBBService m_surface=Surface(native-token=0)
Now it's confirmed, my lone Droid user sent back the 2 log files from:
A test app using MediaRecorder.setPreviewDisplay (Surface sv). It REQUIRES use of getSurface, which crashes in API 5 on Droid phone.
A test app using Camera.setPreviewDisplay(SurfaceHolder sh). It REQUIRES use of MediaRecorder.setCamera for preview, but setCamera is apparently broken "Known limitation - locked camera" in API 3.
So: I Cannot have a previewed media recorder that works on 1.5 and 2.0. So my only option is, (confirmed MediaRecorder.setCamera is not broken in Android2.0 - they added an unlock) is to have two separate versions , one for API 3 and one for API 5.
Thank you commonsware for pointing me in the right direction. I will change the status to "answered" once I try again with deviceanywhere, just to be safe.

LinearLayout of a WebView and a Button

I recently struggled with an apparently simple Android layout: I wanted a WebView above a Button. It worked fine with the following parameters:
WebView:
Height: wrap-content
Weight: unset (by the way, what is the default?)
Button:
Height: wrap-content
Weight: unset
However if the web page became too big it spilled out over the button. I tried various combinations of weights and heights, and all except one either completely hide the button, or partially cover it. This is the one that works (copied from http://code.google.com/p/apps-for-android/source/browse/trunk/Samples/WebViewDemo/res/layout/main.xml):
WebView:
Height: 0
Weight: 1
Button:
Height: wrap-content
Weight: unset
If you change any of those, e.g. give button a weight or change the WebView height to wrap-content then it doesn't work. My question is: Why? Can someone please explain what on Earth the android layout system is thinking?
Something like the following should give you what you want. The key is the layout_height="fill_parent" and layout_weight="1" for the WebView.
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Edit: Whoops, I misunderstood your question. It's the layout_weight that makes it not spill over the button (or textview in your example). I'm not sure why it happens, but if there's one "fill_parent" item in your LinearLayout, in addition to one or more "wrap_content" items, you need to specify a layout_weight for the "fill_parent" item, or it'll take over the space for the rest of the widgets.
Well I since have understood this. The way the android layout system works is:
All the things are laid out according to their specified height/width.
Any remaining weight is distributed among the views according to their weights.
(Obviously this is never explained.)
Therefore to get it to work you want the button to be wrap-content, which makes it just as big as it needs to be, and the webview to be zero height (since it can shrink to zero). After step 1 you will have the button correct, and then webview zero-height.
Then you set the button weight to 0, and the webview weight to 1, so that any remaining space is given to the webview - i.e. it expands to fill the screen.
Makes perfect sense when you know the algorithm.
you can specify the heigth of your webView in pixels
android:layout_heigth = " 70px"
for example
hope it helps
You can try something like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<WebView
android:id="#+id/wv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/btn" />
<Button
android:id="#+id/btn"
android:layout_alignParentBottom="true" />
</RelativeLayout>
Ok, here’s the code to make this:
The above picture has 2 rows of buttons: one on top and one on the bottom. In the middle is the WebView.
Here is my GitHub account where u can download the source code:
https://github.com/GeneChuang1/Android/tree/Android
Otherwise, here is the App breakdown:
The Java Code (AndroidMobileAppSampleActivity.java):
package com.gene;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.gene.R;
public class AndroidMobileAppSampleActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.app_page);
WebView mainWebView = (WebView) findViewById(R.id.webcontent);
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.setWebViewClient(new MyCustomWebViewClient());
mainWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mainWebView.loadUrl("http://www.google.com");
}
private class MyCustomWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
I have 2 XML layouts. One for the main webpage, the other is a pre-made menu that I in the main webpage.
The XML Layout “app_page.xml”:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/page_weekly_items_options_menu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#d4dbe1"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/share"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedShare"></ImageView>
<ImageView
android:id="#+id/left_arrow"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedLeftArrow"></ImageView>
<ImageView
android:id="#+id/right_arrow"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedRightArrow"></ImageView>
<ImageView
android:id="#+id/notifications_pageweeklyitem"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedNotificationsPageWeeklyItem"></ImageView>
<ImageView
android:id="#+id/favorites_pageweeklyitem"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedFavoritesPageWeeklyItem"></ImageView>
</LinearLayout>
<RelativeLayout
android:id="#+id/webcontent_container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#id/page_weekly_items_options_menu">
<WebView
android:id="#+id/webcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/menu"
></WebView>
<include
android:id="#+id/menu"
layout="#layout/bottom_menu"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:layout_weight="1"
/>
</RelativeLayout>
</RelativeLayout>
The other XML layout is “bottom_menu.xml”:
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/bottom_scroll_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >
<!-- This layout is used by activity_main.xml.
It is part of the main home page -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#17528c"
android:orientation="horizontal" >
<ImageView
android:id="#+id/Weekly"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedWeekly" >
</ImageView>
<ImageView
android:id="#+id/Search"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedSearch" >
</ImageView>
<ImageView
android:id="#+id/Favorites"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedFavorites" >
</ImageView>
<ImageView
android:id="#+id/Notifications"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedNotifications" >
</ImageView>
<ImageView
android:id="#+id/Profile"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedProfile" >
</ImageView>
<ImageView
android:id="#+id/About"
android:layout_width="60dp"
android:layout_height="50dp"
android:background="#drawable/icon"
android:clickable="true"
android:onClick="userClickedAbout" >
</ImageView>
</LinearLayout>
</HorizontalScrollView>
The Android Manifest (just incase someone forgets the internet permission):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tscolari.mobile_sample"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".AndroidMobileAppSampleActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Again, here is my GitHub account where u can download the source code:
https://github.com/GeneChuang1/Android/tree/Android
-Gene Chuang

Categories

Resources