Buttons not responding to clicks - Android - android

I have a simple app that updates a counter with plus/minus buttons. I have implemented onClickListeners but I can't get the counter to update based on clicks. I am running my app in an emulator, the application uploads and installs successfully. I also don't see the print statements in the logcat. Please help. Thank you.
package testapp.two;
import testapp.two.R;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener{
Button okButton, minusButton, plusButton;
TextView textScore, scoreCard;
int score = 95;
private static final String TAG = "GolfScore";
/** Called when the activity is first created. */
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG, "onCreate started");
okButton = (Button)findViewById(R.id.buttonOK);
minusButton = (Button)findViewById(R.id.buttonMinus);
plusButton = (Button)findViewById(R.id.buttonPlus);
textScore = (TextView)findViewById(R.id.textScore);
scoreCard = (TextView)findViewById(R.id.scoreCard);
//set button listeners
okButton.setOnClickListener(this);
minusButton.setOnClickListener(this);
plusButton.setOnClickListener(this);
textScore.setText(String.valueOf(score));
Log.d(TAG, "onCreate finished");
}//onCreate
#Override
public void onClick(View v) {
Log.d(TAG, "in onClick");
switch (v.getId()){
case R.id.buttonMinus:
score--;
textScore.setText(String.valueOf(score));
break;
case R.id.buttonPlus:
score++;
textScore.setText(String.valueOf(score));
break;
case R.id.buttonOK:
break;
}//end of switch
}//end of my onclick
}//end of MainActivity
activity 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"
tools:context="${relativePackage}.${activityClass}" >
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="false"
android:layout_centerVertical="false"
android:text="Golf Score App"
android:textAlignment="center" />
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/title"
android:layout_marginTop="14dp"
android:baselineAligned="false"
android:gravity="fill"
android:orientation="horizontal" >
<Button
android:id="#+id/buttonMinus"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:layout_marginLeft="5dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:gravity="center"
android:text="-" />
<Button
android:id="#+id/buttonPlus"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:layout_marginLeft="0dp"
android:layout_weight="1"
android:text="+" />
<TextView
android:id="#+id/textScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="91"
android:textSize="20sp" />
<Button
android:id="#+id/buttonOK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:layout_marginLeft="0dp"
android:layout_marginRight="33dp"
android:layout_weight="1"
android:text="Ok"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:id="#+id/scoreCard"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/LinearLayout1"
android:layout_marginTop="22dp"
android:text="Score card info goes here" />
</RelativeLayout>
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="testapp.two"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

You should probably just declare a new View.OnClickListener() rather than having Main activity implement it... that just seems weird to me. Then set the click listener to that

Related

Loading a URL by using a webview by passing URL in a second activty

I want to pass URL string from main activity to second activity and load the URL in second activity.... but when I click the go button at main activity it goes to second activity but it shows nothing but blank.
here is my code ..
public class MainActivity extends AppCompatActivity {
EditText editText;
Button go;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText=findViewById(R.id.urltext);
go=findViewById(R.id.button6);
final String link=editText.getText().toString();
go.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(),Webview.class);
intent.putExtra("link",link);
startActivity(intent);
}
});
}
}
Second Activity:
public class Webview extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
String one = getIntent().getExtras().getString("link");
String http="https://";
String url=http+one;
WebView webView = (WebView)findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
}
}
Use the following in your manifest :
<uses-permission android:name="android.permission.INTERNET"/>
Refer these examples Please
Web View Android Developers
Can someone give one exact example of webview implementation in android
webView android
your code seems to be fine, just add internet permission in your manifest file
<uses-permission android:name="android.permission.INTERNET"/>
The problem is in this line
final String link=editText.getText().toString();
You have made the variable "link" final that means this variable can be set value only once. Try putting some logs in your code and see what values are passed in the intent extra into the second activity.
Also you have to set WebViewClient to your WebView instance.
Try below code. It worked for me:
private EditText editText;
private Button button;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = (EditText) findViewById(R.id.urltext);
button = (Button) findViewById(R.id.btn_go);
button.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, WebViewActivity.class);
String link = editText.getText().toString();
intent.putExtra("link",link);
startActivity(intent);
}
});
}
In the second activity -
private WebView mWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
String one = getIntent().getExtras().getString("link");
String http="https://";
String url=http+one;
Log.d(WebViewActivity.class.getSimpleName(), url);
mWebView = (WebView)findViewById(R.id.wv_url);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient());
mWebView.loadUrl(url);
}
I have several buttons those I have not used yet. I have used button 6.
Activity mainXML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/backgroundone"
tools:context="com.example.rakib.webbrowser.MainActivity">
<EditText
android:id="#+id/urltext"
android:layout_width="250sp"
android:layout_height="wrap_content"
android:textStyle="italic"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/button"
android:layout_marginTop="20dp"
android:text=""
android:layout_marginRight="15sp"
android:textColor="#FFFF" />
<Button
android:id="#+id/button"
android:background="#drawable/buttonshapehome"
android:text="Facebook"
android:textColor="#fdf900"
android:textStyle="italic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/urltext"
android:layout_marginStart="24dp"
android:layout_marginTop="93dp" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:text="Youtube"
android:textColor="#fdf900"
android:background="#drawable/buttonshapehome"
android:layout_height="wrap_content"
android:textStyle="italic"
android:layout_alignBaseline="#+id/button"
android:layout_alignBottom="#+id/button"
android:layout_marginStart="23dp"
android:layout_toEndOf="#+id/button"
/>
<Button
android:id="#+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Google"
android:textStyle="italic"
android:textColor="#fdf900"
android:background="#drawable/buttonshapehome"
android:layout_alignBaseline="#+id/button2"
android:layout_alignBottom="#+id/button2"
android:layout_marginStart="23dp"
android:layout_toEndOf="#+id/button2"
/>
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:background="#drawable/buttonshapehome"
android:text="linkdin"
android:textColor="#fdf900"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/button"
android:layout_below="#+id/button"
android:textStyle="italic"
android:layout_marginTop="72dp"
/>
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/buttonshapehome"
android:layout_alignBaseline="#+id/button3"
android:layout_alignBottom="#+id/button3"
android:text="gmail"
android:textStyle="italic"
android:textColor="#fdf900"
android:layout_alignStart="#+id/button2"
/>
<Button
android:id="#+id/newage"
android:layout_width="wrap_content"
android:background="#drawable/buttonshapehome"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button4"
android:text="new age"
android:textStyle="italic"
android:textColor="#fdf900"
android:layout_alignBottom="#+id/button4"
android:layout_alignStart="#+id/button5" />
<Button
android:id="#+id/button6"
android:text="GO"
android:layout_width="50dp"
android:textStyle="bold"
android:layout_height="35dp"
android:layout_alignBaseline="#+id/urltext"
android:layout_alignBottom="#+id/urltext"
android:layout_toEndOf="#+id/urltext"
android:background="#039337"
/>
<Button
android:id="#+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/button3"
android:layout_marginBottom="53dp"
android:background="#drawable/settings_icon"
android:text=""
android:textColor="#ffaa00" />``
<TextView
android:id="#+id/textView"
android:text="settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/button8"
android:layout_alignParentBottom="true"
android:layout_marginBottom="27dp"
android:layout_marginEnd="16dp"
android:textColor="#ffff" />
</RelativeLayout>
Activity webviewXML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.rakib.webbrowser.Webview">
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="470dp">
</WebView>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_below="#id/webview"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:background="#00ffffff"
>
<ImageView
android:id="#+id/home"
android:src="#drawable/homeicon"
android:clickable="true"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="36sp"
tools:ignore="OnClick" />
<ImageView
android:id="#+id/reload"
android:layout_weight="1"
android:clickable="true"
android:src="#drawable/reload"
android:layout_height="36sp"
android:layout_width="wrap_content"
/>
</LinearLayout>
and this is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rakib.webbrowser">
<uses-permission android:name="android.permission.INTERNET">
</uses-permission>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Webview">
</activity>
</application>
</manifest>

"Unfortunately,<App name> has stopped working" Pops up whenever i click a button

I am trying to make a simple calculator using android studio. However when i click the button with text "1", the app crashes and the button with text "2" doesn't
do anything. I have rightly added android:Onclick = "" to the xml. Please have a look at different source code files.
**PS: For now, I am trying to make the first two buttons work **
activity_main.xml
<?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"
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="com.example.meenakshi.calculator.MainActivity">
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_text"
android:id="#+id/button"
android:layout_row="0"
android:layout_column="0"
android:textColor="#color/abc_search_url_text_pressed"
android:nestedScrollingEnabled="false"
android:onClick="press1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button16"
android:layout_row="0"
android:layout_column="3"
android:text="#string/buttond_text" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button4_text"
android:id="#+id/button4"
android:layout_row="1"
android:layout_column="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text= "#string/button2_text"
android:id="#+id/button2"
android:layout_row="0"
android:layout_column="1"
android:onClick="press2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button3_text"
android:id="#+id/button3"
android:layout_row="0"
android:layout_column="2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/buttonmul_text"
android:id="#+id/button15"
android:layout_row="1"
android:layout_column="3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button7_text"
android:id="#+id/button7"
android:layout_row="2"
android:layout_column="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button5_text"
android:id="#+id/button5"
android:layout_row="1"
android:layout_column="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button6_text"
android:id="#+id/button6"
android:layout_row="1"
android:layout_column="2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button8_text"
android:id="#+id/button8"
android:layout_row="2"
android:layout_column="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/buttonm_text"
android:id="#+id/button14"
android:layout_row="2"
android:layout_column="3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button._text"
android:id="#+id/button12"
android:layout_row="3"
android:layout_column="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button0_text"
android:id="#+id/button10"
android:layout_row="3"
android:layout_column="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button9_text"
android:id="#+id/button9"
android:layout_row="2"
android:layout_column="2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/buttone_text"
android:id="#+id/button11"
android:layout_row="3"
android:layout_column="2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/buttonp_text"
android:id="#+id/button13"
android:layout_row="3"
android:layout_column="3" />
</GridLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/result"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="32dp"
android:inputType="text" />
</RelativeLayout>
MainActivity.java
package com.example.meenakshi.calculator;
import android.content.DialogInterface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.EditText;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
Button btn = (Button)findViewById(R.id.button);
EditText edittext = (EditText)findViewById(R.id.result);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void press1(View v){
edittext.setText("1");
}
public void press2(View v){
edittext.setText("2");
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.meenakshi.calculator">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Stack trace
java.lang.IllegalStateException: Could not find method press(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'button'
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:327)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:284)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
The problem here is that Activity has lifecycle and here we have following sequence of events:
initialisation of fields <- here you initialised Button and EditText(at this moment there is no layout, so findViewById returns null)
onCreate() <- here you inflating layout (after setContentView() you can find your views in layout)
Some recommendations:
Do not use onClick in xml - it makes it not obvious that something listens to onClick Event and in often (this case too) it is the root of problems. Use findViewById(R.id.button).setOnClickListener(); it makes that obvious.
onCreate() should be the method to initialise everything in your activity
UPDATE
In the end you would have something like:
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private EditText result;
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
result = (EditText) findViewById(R.id.result);
findViewById(R.id.button1).setOnClickListener(this);
findViewById(R.id.button2).setOnClickListener(this);
}
#Override
public void onClick(View v) {
Button clickedBtn = (Button) v;
switch (v.getId()){
case (R.id.button1):
case (R.id.button2):
result.append(clickedBtn.getText());
break;
default:
//some other
break;
}
}
}
Note: it is better NOT to put numbers and signs to strings.xml - despite AS complains about that, but you will not reuse that in your program and there is no case about translating those strings :)
Edit
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button)findViewById(R.id.button);
Button btn2 = (Button)findViewById(R.id.button2);
EditText edittext = (EditText)findViewById(R.id.result);
}
Try this:
public class MainActivity extends AppCompatActivity {
Button btn;
EditText edittext;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edittext = (EditText)findViewById(R.id.result);
btn = (Button)findViewById(R.id.button);
}
You must call findViewById() after setContentView().
Calling
Button btn = (Button)findViewById(R.id.button);
EditText edittext = (EditText)findViewById(R.id.result);
outside any method will cause it to execute right in constructor which only Android system calls before calling onCreate() on instance on your activity. Which at that time will return null. Later in onCreate() method you are setting the content view for this activity
setContentView(R.layout.activity_main);
So please move those two lines after you call setContentView() in onCreate() method.

pass intent with extra to defined layout text view

I am at the beginning of an app, I'm an absolute amateur and what i want to do is simple.
I am trying to pull Extras from an intent on my first activity into a textview on my second activity
First page: what is your name? (type a name and push a button)
On the next page: okay so your name is ...(the name they entered)
I had an answer to this but had a little trouble understanding it, in the code i have, when i click the okay button just the word okay shows up in the textview rather than the edited text
here is my code....
main.java
Button ok;
EditText name;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
name=(EditText)findViewById(R.id.editText);
ok=(Button)findViewById(R.id.button);
ok.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
String a=ok.getText().toString();
Intent intent = new Intent(getApplicationContext(), secondactivity.class);
intent.putExtra("NAMEDATA",a);
startActivity(intent);
}
});
}
main.xml
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/okay_button"
android:id="#+id/button"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:textStyle="bold|italic"
android:textSize="23sp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignBottom="#+id/button"
android:hint="#string/text"
android:textSize="25sp"
android:textStyle="bold|italic"
android:layout_toLeftOf="#+id/button"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:src="#drawable/start"
android:contentDescription="#string/startimage"
android:layout_below="#+id/button"
android:paddingBottom="20dp"
android:paddingTop="20dp"/>
</RelativeLayout>
secondactivity.java
public class secondactivity extends Activity {
TextView t;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
t = (TextView)findViewById(R.id.textView3);
String n = this.getIntent().getStringExtra("NAMEDATA");
t.setText(n);
}
activity_second.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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".SecondActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name_sent"
android:textSize="23sp"
android:id="#+id/textView2"
android:textStyle="bold|italic"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/what_to_do"
android:id="#+id/textView"
android:layout_marginTop="13dp"
android:textSize="23sp"
android:layout_below="#+id/textView2"
android:textStyle="bold|italic"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/bath_time"
android:id="#+id/button"
android:layout_marginTop="29dp"
android:layout_below="#+id/textView"
android:layout_alignRight="#+id/textView"
android:layout_alignLeft="#+id/textView"
android:textSize="25sp"
android:textStyle="bold|italic"
android:onClick="viewimage"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/school"
android:id="#+id/button2"
android:layout_below="#+id/button"
android:layout_alignRight="#+id/button"
android:layout_alignLeft="#+id/button"
android:textSize="25sp"
android:textStyle="bold|italic"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/bed"
android:id="#+id/button3"
android:layout_below="#+id/button2"
android:layout_alignLeft="#+id/button2"
android:layout_alignRight="#+id/button2"
android:textSize="25sp"
android:textStyle="bold|italic"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_alignTop="#+id/textView2"
android:layout_toRightOf="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:paddingStart="4dp"
android:layout_alignParentRight="true"
android:textSize="23dp"
android:textStyle="bold|italic" />
</RelativeLayout>
androidmainfest.xml
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".main"
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=".secondactivity"
android:label="#string/title_activity_second" >
</activity>
<activity
android:name=".bathactivity"
android:label="#string/title_activity_bath"
android:parentActivityName="com.example.myapplication.SecondActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myapplication.SecondActivity" />
</activity>
</application>
can anyone tell me where I've gone wrong? Think its in my onCreate method on either Activity but really stuck,
many thanks
Actually - you don't pass anything from the EditText widget, you are only passing from the Button
Here lies the problem:
String a=ok.getText().toString();
Intent intent = new Intent(getApplicationContext(), secondactivity.class);
intent.putExtra("NAMEDATA",a);
You could add the contents of the EditText onto the end of this string in the same way.
Try something like this:
String nameStr = name.getText().toString();
String a = ok.getText().toString();
Intent intent = new Intent(getApplicationContext(), secondactivity.class);
intent.putExtra("NAMEDATA",a+nameStr);

Webview won't load on button click?

I have been trying to resolve this now for a number of days, I have searched the web and have also scoured through the many related questions provided on here but I am yet to resolve this issue.
The code works fine when I create a separate project, but the some reason it is not working here.
I have several activities that are accessible buy a click of a button from the main page (This part is working fine) and then from each of those several activities I have buttons that when clicked should open a website, but it is not happening.....
I have added all activities to the Manifest ( what I can see) have looked at it several times. lol
I've redone the code several times but to no avail, the only thing I have not done is start the project from scratch (Last resort).
Appreciate your help.
**
MainActivity.java (Main Page Working Fine)
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class MainActivity extends Activity {
ImageButton imagebutton1, imagebutton2,imagebutton3, imagebutton4,
imagebutton5, imagebutton6;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addListenerOnButton();
}
public void addListenerOnButton() {
final Context context = this;
imagebutton1 = (ImageButton) findViewById(R.id.imageButton1);
imagebutton1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent intent = new Intent(context, Fashion.class);
startActivity(intent);
}
});
imagebutton2 = (ImageButton) findViewById(R.id.imageButton2);
imagebutton2.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent intent = new Intent(context, Electrical.class);
startActivity(intent);
}
});
imagebutton3 = (ImageButton) findViewById(R.id.imageButton3);
imagebutton3.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent intent = new Intent(context, Kids.class);
startActivity(intent);
}
});
imagebutton4 = (ImageButton) findViewById(R.id.imageButton4);
imagebutton4.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent intent = new Intent(context, Pets.class);
startActivity(intent);
}
});
imagebutton5 = (ImageButton) findViewById(R.id.imageButton5);
imagebutton5.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent intent = new Intent(context, Food.class);
startActivity(intent);
}
});
imagebutton6 = (ImageButton) findViewById(R.id.imageButton6);
imagebutton6.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent intent = new Intent(context, Web.class);
startActivity(intent);
}
});
}
}
**
MainActivityWebview.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivityWebView extends Activity {
private Button button1, button2;
public void onCreate(Bundle savedInstanceState) {
final Context context = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.fashion);
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent intent = new Intent(context, WebViewActivitySelfridges.class);
startActivity(intent);
}
});
button2 = (Button) findViewById(R.id.button2);
button2.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent intent = new Intent(context, WebViewActivityVery.class);
startActivity(intent);
}
});
}
}
fashion.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:background="#FFFFFF"
>
<ScrollView
android:id="#+id/tabscrvie"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TableLayout
android:id="#+id/gridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:src="#drawable/selfridges" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Store" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:src="#drawable/very" />
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:src="#drawable/nelly" />
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:baselineAlignBottom="false"
android:cropToPadding="true"
android:src="#drawable/george" />
<Button
android:id="#+id/button4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:baselineAlignBottom="false"
android:cropToPadding="true"
android:src="#drawable/redoute" />
<Button
android:id="#+id/button5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:baselineAlignBottom="false"
android:cropToPadding="true"
android:src="#drawable/fraser" />
<Button
android:id="#+id/button6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:baselineAlignBottom="false"
android:cropToPadding="true"
android:src="#drawable/lncc" />
<Button
android:id="#+id/button7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:src="#drawable/selfridges" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Store" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:src="#drawable/very" />
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:src="#drawable/nelly" />
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:baselineAlignBottom="false"
android:cropToPadding="true"
android:src="#drawable/george" />
<Button
android:id="#+id/button4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:baselineAlignBottom="false"
android:cropToPadding="true"
android:src="#drawable/redoute" />
<Button
android:id="#+id/button5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:baselineAlignBottom="false"
android:cropToPadding="true"
android:src="#drawable/fraser" />
<Button
android:id="#+id/button6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:baselineAlignBottom="false"
android:cropToPadding="true"
android:src="#drawable/lncc" />
<Button
android:id="#+id/button7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1"
android:text="Visit Website" />
</TableRow>
</TableLayout>
</ScrollView>
</RelativeLayout>
WebViewActivitySelfridges.java
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class WebViewActivitySelfridges extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.selfridges.com/");
}
}
WebViewActivityVery.java
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class WebViewActivityVery extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.very.co.uk/");
}
}
webview.xml
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="store.front"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="store.front.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>
<activity
android:label="#string/app_name"
android:name="store.front.WebViewActivitySelfridges" >
</activity>
<activity
android:label="#string/app_name"
android:name="store.front.WebViewActivityVery" >
</activity>
<activity
android:label="#string/app_name"
android:name="store.front.Fashion" >
</activity>
<activity
android:label="#string/app_name"
android:name="store.front.Electrical" >
</activity>
<activity
android:label="#string/app_name"
android:name="store.front.Kids" >
</activity>
<activity
android:label="#string/app_name"
android:name="store.front.Food" >
</activity>
<activity
android:label="#string/app_name"
android:name="store.front.Pets" >
</activity>
<activity
android:label="#string/app_name"
android:name="store.front.Web" >
</activity>
<activity
android:label="#string/app_name"
android:name="store.front.MainActivityWebView" >
</activity>
</application>
</manifest>
Not completely sure if this is correct.
#Override is missing in onCreate of all the webview activities defined by you.
Check if the onCreate() is getting triggered at all.

android listview don't apprear when implement it with Activity, not listActivity

i want to put listview into a layout and i want to use just Activity class , not listActivity, i saw these two questions
First
Second
and i did the exactly what they say, but i still have nothing apprear in the listview
Java code
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class FoodsMenu extends Activity {
String foods[] = { "Betza" };
ListView lvFoods;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.foodsmenu);
initialize();
}
private void initialize() {
// TODO Auto-generated method stub
lvFoods = (ListView) findViewById(R.id.lvFoods);
lvFoods.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, foods));
}
}
layout code foodsmenu.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ListView
android:id="#+id/lvFoods"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#333333"
android:fillViewport="true" >
</ListView>
<LinearLayout
android:layout_width="40dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#ffffff"
android:orientation="vertical" >
<TextView
android:id="#+id/tvA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="A"
android:textColor="#025f7c"
android:textSize="13dp" />
<TextView
android:id="#+id/tvB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="B"
android:textColor="#025f7c"
android:textSize="13dp" />
<TextView
android:id="#+id/tvC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="C"
android:textColor="#025f7c"
android:textSize="13dp" />
<TextView
android:id="#+id/tvD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="D"
android:textColor="#025f7c"
android:textSize="13dp" />
</LinearLayout>
</LinearLayout>
what is the wrong with my works please?
check the attached image. This is the screen shot of the samsung galxy tab with your code only and its working.
Below is the complete code i tested.
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class TestSamplesActivity extends Activity {
String foods[] = { "Betza", "Betza1", "Betza2", "Betza3", "Betza4" };
ListView lvFoods;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.foodsmenu);
initialize();
}
private void initialize() {
// TODO Auto-generated method stub
lvFoods = (ListView) findViewById(R.id.lvFoods);
lvFoods.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, foods));
}
}
foodsmenu.xml.
<?xml version="1.0" encoding="utf-8"?>
<ListView
android:id="#+id/lvFoods"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#333333"
android:fillViewport="true" >
</ListView>
<LinearLayout
android:layout_width="40dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#ffffff"
android:orientation="vertical" >
<TextView
android:id="#+id/tvA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="A"
android:textColor="#025f7c"
android:textSize="13dp" />
<TextView
android:id="#+id/tvB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="B"
android:textColor="#025f7c"
android:textSize="13dp" />
<TextView
android:id="#+id/tvC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="C"
android:textColor="#025f7c"
android:textSize="13dp" />
<TextView
android:id="#+id/tvD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="D"
android:textColor="#025f7c"
android:textSize="13dp" />
</LinearLayout>
</LinearLayout>
manifest
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".TestSamplesActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
compare with your code if anything is missed.
Replace width="match_parent" of listview and width="40dp" of linear to 0dp
Adjust your weights accordingly like 0.8 for list and 0.2 for linear etc

Categories

Resources