Gå til innhold

[Løst] Java error Android Studio


Anbefalte innlegg

Hei,

 

Noob på java feil her. Noen som kan se hvor feilen oppstår?
Får FATAL EXCEPTION: main

                  Process: no.fastfood.fastfood_haugaland, PID: 28207

Fra mainpage.xml:

-----------------------------------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
tools:context="no.fastfood.fastfood_haugaland.Mainpage"
android:background="#ebebe0"
android:orientation="vertical"
android:weightSum="1"
>



<ImageView
android:layout_width="fill_parent"
android:layout_height="100dp"
android:scaleType="fitXY"
android:id="@+id/logo"
android:layout_gravity="center_horizontal"
android:src="@drawable/logo" />


<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Her Velger du Kommunen "
android:id="@+id/textView"
android:layout_gravity="center"
android:layout_weight="0.91"
android:fontFamily="sans-serif"
android:textAlignment="center"
android:textSize="35dp"/>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="347dp">

<ImageButton
android:layout_width="100dp"
android:layout_height="158dp"
android:id="@+id/karmoy"
android:layout_gravity="right|top"
android:src="@drawable/karmoy"
android:scaleType="centerCrop"/>

<ImageButton
android:layout_width="100dp"
android:layout_height="158dp"
android:id="@+id/tysver"
android:layout_gravity="right|bottom"
android:src="@drawable/tysver"
android:scaleType="centerCrop"/>

<ImageButton
android:layout_width="100dp"
android:layout_height="158dp"
android:src="@drawable/haugesund"
android:id="@+id/haugesundk"
android:scaleType="centerCrop"
android:layout_gravity="left|top" />

<ImageButton
android:layout_width="100dp"
android:layout_height="158dp"
android:id="@+id/bokn"
android:layout_gravity="left|bottom"
android:src="@drawable/bokn"
android:scaleType="centerCrop"/>

<ImageButton
android:layout_width="100dp"
android:layout_height="158dp"
android:id="@+id/sveio"
android:layout_gravity="top|center_horizontal"
android:src="@drawable/sveio"
android:scaleType="centerCrop"/>

<ImageButton
android:layout_width="100dp"
android:layout_height="158dp"
android:id="@+id/utsira"
android:layout_gravity="center_horizontal|bottom"
android:src="@drawable/utsira"
android:scaleType="centerCrop"/>
</FrameLayout>


</LinearLayout>


------------------------------------------------------------------------------------------------------------------------------

 

Fra mainpage.java:

 

 

package no.fastfood.fastfood_haugaland;

import android.content.Intent;
import android.media.Image;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;

public class Mainpage extends AppCompatActivity {



ImageButton haugesundk;
ImageButton karmoy;
ImageButton sveio;
ImageButton utsira;
ImageButton bokn;
ImageButton tysver;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mainpage);
OnClickButtonListener1();
OnClickButtonListener2();
OnClickButtonListener3();
OnClickButtonListener4();
OnClickButtonListener5();
OnClickButtonListener6();

ImageView myImageView = (ImageView) findViewById(R.id.logo);
myImageView.setImageResource(R.drawable.logo);


}

public void OnClickButtonListener1 () {
haugesundk = (ImageButton) findViewById(R.id.haugesundk);
haugesundk.setOnClickListener (
new View.OnClickListener () {
@Override
public void onClick(View view) {
Intent intent = new Intent("no.fastfood.fastfood_haugaland.haugesund");
startActivity(intent);
}
}
);
}

public void OnClickButtonListener2() {
karmoy = (ImageButton) findViewById(R.id.karmoy);
karmoy.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("no.fastfood.fastfood_haugaland.karmoy");
startActivity(intent);
}
}
);
}
public void OnClickButtonListener3() {
sveio = (ImageButton) findViewById(R.id.sveio);
sveio.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("no.fastfood.fastfood_haugaland.sveio");
startActivity(intent);
}
}
);
}

public void OnClickButtonListener4() {
bokn = (ImageButton) findViewById(R.id.bokn);
bokn.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("no.fastfood.fastfood_haugaland.bokn");
startActivity(intent);
}
}
);
}

public void OnClickButtonListener5() {
tysver = (ImageButton) findViewById(R.id.tysver);
tysver.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("no.fastfood.fastfood_haugaland.tysver");
startActivity(intent);
}
}
);

}

public void OnClickButtonListener6() {
utsira = (ImageButton) findViewById(R.id.utsira);
utsira.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("no.fastfood.fastfood_haugaland.utsira");
startActivity(intent);
}
}
);
}


}


 

Lenke til kommentar
Videoannonse
Annonse

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...