>
> It seems i implemented the OnClickListener correctly, my phone makes a
> sound when i click the button
>
Just because you get a sound when you press the button doesn't mean that
you implemented your OnClickListener correctly.
> Intent i = new Intent(this, dagensbilde.class); *there is an error
> here: The constructor Intent(new View.OnClickListener(){},
> Class<dagensbilde>) is undefined
>
Your intent declaration should be as follows:
Intent i = new Intent(BrowserActivity.this, dagensbilde.class);
Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware
On Thu, Jun 14, 2012 at 12:07 PM, Lars <[email protected]> wrote:
> It seems i implemented the OnClickListener correctly, my phone makes a
> sound when i click the button, but does'nt open the next activity. My code
> is below, but i don't know what the error means.
>
> btw i bought a book a couple a months ago; Hello android, third edition.
> It got me started but it seems to be no good at debugging. Especially
> becuase i wrote exactly what it told me(with the exeptions of the buttons
> names etc.).
>
> Thank you very much :)
>
> public class BrowserActivity extends Activity {
> protected void onCreate(Bundle icicle) {
> super.onCreate(icicle);
>
> setContentView(R.layout.main);
>
> final Button dagens_button = (Button)
> findViewById(R.id.dagens_button);
> dagens_button.setOnClickListener(new View.OnClickListener() {
> public void onClick(View v) {
> switch (v.getId()){
> case R.id.dagens_button:
> Intent i = new Intent(this, dagensbilde.class); *there is an
> error here: The constructor Intent(new View.OnClickListener(){},
> Class<dagensbilde>) is undefined
> startActivity(i);
> break;
> }
> // Perform action on click
> }
> });
> }{;
> }}
>
> Den onsdag den 13. juni 2012 20.45.49 UTC+2 skrev Chris Ruskai:
>
>> If that's your entire Activity, I don't see an onCreate function or
>> anything that calls setContentView to tell the app which xml file to use
>> for the activity's layout.
>>
>> For example:
>>
>> @Override
>> public void onCreate(Bundle savedInstanceState) {
>> super.onCreate(**savedInstanceState);
>> setContentView(R.layout.main);
>> }
>>
>> On Wed, Jun 13, 2012 at 11:22 AM, Lars <[email protected]> wrote:
>>
>>> Here's my activity.java:
>>>
>>> package lars.browser;
>>>
>>> import lars.browser.dagensbilde;
>>> import android.app.Activity;
>>> import android.os.Bundle;
>>> import android.content.Intent;
>>> import android.view.View;
>>> import android.view.View.**OnClickListener;
>>>
>>>
>>> public class BrowserActivity extends Activity {
>>> /** Called when the activity is first created. */
>>> public void onClick(View v) {
>>> if (v.getId() == R.id.dagens_button) {
>>> View dagens_button = findViewById(R.id.dagens_**button);
>>> dagens_button.**setOnClickListener((**OnClickListener) this);
>>> Intent i = new Intent(this, dagensbilde.class);
>>> startActivity(i);
>>>
>>> And here's my main.xml
>>>
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <LinearLayout xmlns:android="http://schemas.**
>>> android.com/apk/res/android <http://schemas.android.com/apk/res/android>
>>> "
>>> android:layout_width="match_**parent"
>>> android:layout_height="fill_**parent"
>>> android:background="@color/**background"
>>> android:orientation="**horizontal"
>>> android:padding="30dip" >
>>>
>>> <LinearLayout
>>> android:orientation="vertical"
>>> android:layout_height="wrap_**content"
>>> android:layout_width="fill_**parent"
>>> android:layout_gravity="**center">
>>> <TextView
>>> android:text="@string/main_**title"
>>> android:layout_height="wrap_**content"
>>> android:layout_width="wrap_**content"
>>> android:layout_gravity="**center"
>>> android:layout_marginBottom="**25dip"
>>> android:textSize="24.5sp"/>
>>>
>>>
>>> <Button
>>> android:id="@+id/nyeste_**button"
>>> android:layout_width="265dp"
>>> android:layout_height="wrap_**content"
>>> android:layout_gravity="**center"
>>> android:text="@string/nyeste_**text"
>>> android:textSize="20sp" />
>>>
>>>
>>> <Button
>>> android:id="@+id/dagens_**button"
>>> android:layout_width="265dp"
>>> android:layout_height="wrap_**content"
>>> android:layout_gravity="**center"
>>> android:text="@string/dagens_**text"
>>> android:textSize="20sp" />
>>>
>>> <Button
>>> android:id="@+id/måneds_**button"
>>> android:layout_width="265dp"
>>> android:layout_height="wrap_**content"
>>> android:text="@string/måneds_**text"
>>> android:layout_gravity="**center"
>>> android:textSize="20sp"/>
>>> <Button
>>> android:id="@+id/alltid_**button"
>>> android:layout_width="265dp"
>>> android:layout_height="wrap_**content"
>>> android:text="@string/alltid_**text"
>>> android:layout_gravity="**center"
>>> android:textSize="20sp"/>
>>> <Button
>>> android:id="@+id/aboutdev_**button"
>>> android:layout_width="265dp"
>>> android:layout_height="wrap_**content"
>>> android:text="@string/**aboutdev_button"
>>> android:layout_gravity="**center"
>>> android:textSize="20sp"/>
>>> </LinearLayout>
>>> </LinearLayout>
>>>
>>>
>>> Please tell me if i need anything.
>>>
>>> Den onsdag den 13. juni 2012 01.52.28 UTC+2 skrev cellurl:
>>>
>>>> Get Jetboy working first.
>>>> http://www.udemy.com/write-**and**-publish-an-app-for-your-**andro**
>>>> id-smartphone/<http://www.udemy.com/write-and-publish-an-app-for-your-android-smartphone/>
>>>> It will teach you a lot and only take 1hour.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Tue, Jun 12, 2012 at 5:50 PM, Justin Anderson <[email protected]
>>>> > wrote:
>>>>
>>>>> Without seeing your code there is no way of knowing...
>>>>>
>>>>> Thanks,
>>>>> Justin Anderson
>>>>> MagouyaWare Developer
>>>>> http://sites.google.com/site/**m**agouyaware<http://sites.google.com/site/magouyaware>
>>>>>
>>>>>
>>>>> On Thu, Jun 7, 2012 at 1:21 PM, Lars <[email protected]> wrote:
>>>>>
>>>>>> Hello
>>>>>> I am new at this site and new at developing.
>>>>>> The first activity in my application has 5 buttons, every one of them
>>>>>> should(at som point when I get it done) lead to a web page using the
>>>>>> "webview" wigdet. Eclipse does'nt show any errors or mistakes in the code
>>>>>> ANYWHERE.
>>>>>>
>>>>>> BUT, when I try to run the app on my phone it only shows my
>>>>>> background color and the applications name.
>>>>>>
>>>>>> This is what Eclipse shows (picture is taken with my phone) in
>>>>>> main.xml
>>>>>>
>>>>>> <https://lh6.googleusercontent.com/-Eh4Mstm6RTI/T9D-o7D2CsI/AAAAAAAAEdo/mNDvt-qH0k8/s1600/IMG_20120607_211404.jpg>
>>>>>> This is what my phone shows: as you can see theres something wrong.
>>>>>> but what? please help me. Thanks, Lars.
>>>>>>
>>>>>> <https://lh6.googleusercontent.com/-hF-KuNJLMk8/T9D9_s8LeXI/AAAAAAAAEdY/_iry-jMFNv4/s1600/Screenshot_2012-06-07-19-05-04.png>
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Android Developers" group.
>>>>>> To post to this group, send email to android-developers@**googlegroup
>>>>>> **s.com <[email protected]>
>>>>>> To unsubscribe from this group, send email to
>>>>>> android-developers+**unsubscribe**@googlegroups.com<android-developers%[email protected]>
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/**group**/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>
>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Android Developers" group.
>>>>> To post to this group, send email to android-developers@**googlegroup*
>>>>> *s.com <[email protected]>
>>>>> To unsubscribe from this group, send email to
>>>>> android-developers+**unsubscribe**@googlegroups.com<android-developers%[email protected]>
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/**group**/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>
>>>>
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to android-developers@**
>>> googlegroups.com <[email protected]>
>>> To unsubscribe from this group, send email to
>>> android-developers+**[email protected]<android-developers%[email protected]>
>>> For more options, visit this group at
>>> http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>
>>>
>>
>> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en