[Android Q&A, Help & Troubleshooting] dillenge:
I have been working on this project for a while now and cant seen to find the error in my program

package com.dillon.time;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

public class MainActivity extends Activity {

private ListView m_listview;
Random random = new Random();
int hoursRemaining = 24;
int shelterStability = 0;
int energyLevel = 100;
int intResources = 0;
int intFood = 0;
int dayCounter = 1;
int hunger = 50;
int timerValue = 1;
ArrayList<String> ar = new ArrayList<String>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

m_listview = (ListView) findViewById(R.id.listView);
ar.add("You wake up in a strange land feeling energetic");
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, ar);

m_listview.setAdapter(adapter);

setIntFood();
setIntResources();
setHoursRemaining();
setShelterStability();
setEnergyLevel();
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
if (energyLevel == 0){
energyLevel = 50;
setEnergyLevel();
hourChecker(9);
shelterChecker(9);
randomEventGeneratorChecker(4);
addString("You passed out due to exhaustion and woke up 9 hours later");
}
if (hoursRemaining == 0) {
dayCounter += 1;
hoursRemaining = 24;
setHoursRemaining();
}
}
}, 0, 1);
}

public void setEnergyLevel() {
TextView energy = (TextView) findViewById(R.id.energy);

energy.setText("Energy: " + energyLevel + "%");
}

public void setShelterStability() {
TextView shelter = (TextView) findViewById(R.id.shelter);
shelter.setText("Shelter Stability: " + shelterStability + "%");

}

public void setHoursRemaining() {
TextView hours = (TextView) findViewById(R.id.timeRemaining);
hours.setText("Day: " + dayCounter + " Time Remaining: " + hoursRemaining + "h");
}

public void setIntResources() {
TextView resources = (TextView) findViewById(R.id.resources);
if(shelterStability != 0) {
resources.setText("Resources: " + intResources + "lb");
}
else{
resources.setText("Resources: " + 0 + "lb");
}
}

public void setHunger(int x){
TextView hunger1 = (TextView) findViewById(R.id.hunger);
if(x>=90){
hunger1.setText("Full");
}
else if(x < 90 && x > 50){
hunger1.setText("Well Fed");
}
else if(x <= 50 && x >= 15){
hunger1.setText("Hungry");
}
else if(x < 15 && x >= 1){
hunger1.setText("Starving");
}
else if(x == 0){
hunger1.setText("Starved");
addString("You starved to death.");
sleep(1);
gameOver();
switchView();
}
}

public void setIntFood() {
TextView food = (TextView) findViewById(R.id.food);
food.setText("Food: " + intFood + "lb");
}

public void eat(View v) {
if (intFood >= 1) {
hourChecker(1);
if (hunger <= 95) {
hunger += 5;
setHunger(hunger);
TextView hunger2 = (TextView) findViewById(R.id.hunger);
addString("You eat 1lb of food and are now " + hunger2.getText() );
} else {
hunger = 100;
setHunger(hunger);
}
intFood -= 1;
setIntFood();
shelterChecker(1);
}

}

public void addString(String x) {
ar.add(x);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, ar);
m_listview.setAdapter(adapter);
}

public void repairShelter(View v) {
if (shelterStability != 100 && intResources >= 20 && energyLevel >= 20) {
hourChecker(1);
hungerChecker(1);
energyLevel -= 20;
setEnergyLevel();
if (intResources >= 20) {
intResources -= 20;
setIntResources();
}
int percent = 100 - shelterStability;
if (percent <= 40) {
int newStability = 100 - shelterStability;
shelterStability = 100;
setShelterStability();
addString("You use 20lbs of material and repair your shelter by " + newStability + "%");
} else {
shelterStability += 40;
setShelterStability();
addString("You use 20lbs of material and repair your shelter by " + 40 + "%");
}
}
}

public void raidSomeone(View v) {
int rand = random.nextInt(4 - 1 + 1) + 1;
int energyNew = rand * 5;
if (energyLevel >= energyNew) {
hourChecker(rand);
energyLevel -= rand * 5;
setEnergyLevel();
hungerChecker(rand);
shelterChecker(rand);
int rand1 = random.nextInt(3 - 1 + 1) + 1;
if (rand1 != 1) {
if (rand1 == 2) {
int rand2 = random.nextInt(10 - 0 + 1) + 0;
int rand3 = random.nextInt(10 - 0 + 1) + 0;
intResources += rand2;
setIntResources();
intFood += rand3;
setIntFood();
addString("You stumbled upon an empty camp and acquired " + rand3 + "lb(s) of food and " + rand2 + "lb(s) of material");
} else {
int rand2 = random.nextInt(40 - 20 + 1) + 0;
int rand3 = random.nextInt(40 - 20 + 1) + 0;
intResources += rand2;
setIntResources();
intFood += rand3;
setIntFood();
addString("You stumbled upon a fortified camp and acquired " + rand3 + "lbs of food and " + rand2 + "lbs of material");
}
} else {
addString("You spent " + rand + " hour(s) searching for a camp and found nothing.");
}
}
}

public void shelterChecker(int x) {
if (shelterStability >= x) {
shelterStability -= x;
setShelterStability();
} else {
shelterStability = 0;
setShelterStability();
}
}

public void scavenge(View v) {
if (energyLevel >= 10) {
hourChecker(1);
energyLevel -= 10;
setEnergyLevel();
int rand = random.nextInt(5 - 0 + 1) + 0;
intResources += rand;
addString("You spent 1 hour scavenging for materials and found " + rand + "lb(s) of material");
setIntResources();
shelterChecker(1);
hungerChecker(1);
}
}

public void sleep(int x) {
try {
TimeUnit.SECONDS.sleep(x);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}

public void hourChecker(int x) {
if (hoursRemaining >= x)
{
hoursRemaining -= x;
setHoursRemaining();
}
else
{
hoursRemaining = 24 - (x - hoursRemaining);
dayCounter += 1;
setHoursRemaining();
}
}

public void randomEventGeneratorChecker(int x){
int realDayCounter = dayCounter*x;
if(realDayCounter <= 24) {
randomEventGenerator(realDayCounter);
}
else{
randomEventGenerator(24);
}
}

public void sleepButton(View v){
energyLevel = 100;
setEnergyLevel();
hourChecker(9);
shelterChecker(9);
hungerChecker(9);
randomEventGeneratorChecker(1);
addString("You slept for 9 hours");
}

public void hunt(View v){
if(energyLevel >= 5) {
hourChecker(1);
energyLevel -= 5;
setEnergyLevel();
int rand = random.nextInt(3 - 0 + 1) + 0;
intFood += rand;
addString("You spent 1 hour hunting and aquired "+ rand + "lb(s) of food");
setIntFood();
shelterChecker(1);
hungerChecker(1);
}
}

public void randomEventGenerator(int x){
int rand = random.nextInt(25 - x + 1) + x;
if(rand == 25) {
int event = random.nextInt(2 - 1 + 1) + 1;
switch (event) {
case 1:

if(shelterStability <= 30){
int rand1 = random.nextInt(3 - 1 + 1) + 1;
if(rand1 == 1){
addString("Raiders came in the night and tried to break in. They succeeded and killed you");
sleep(2);
gameOver();
switchView();
}
else{
int rand2 = random.nextInt(30 - 10 + 1) + 10;
foodChecker(rand2);
int rand3 = random.nextInt(30 - 10 + 1) + 10;
resourceChecker(rand3);
if(rand2 >= intFood && rand3 <= intResources) {
addString("Raiders came in the night and tried to break in. They succeeded and stole all of your food and " + rand3 + "lbs of material");
}
if(rand2 <= intFood && rand3 >= intResources){
addString("Raiders came in the night and tried to break in. They succeeded and stole " + rand2 + "lbs of food and all of your materials");
}
if(rand2 >= intFood && rand3 >= intResources){
addString("Raiders came in the night and tried to break in. They succeeded and stole all of your food and all of your materials");
}
if(rand2 <= intFood && rand3 <= intResources){
addString("Raiders came in the night and tried to break in. They succeeded and stole " + rand2 + "lbs of your food and "+ rand3 + "lbs of material");
}
}
}
else{
addString("Raiders came in the night and tried to break in, but your base was too strong");
}
break;
case 2:
if(shelterStability <= 50) {
int rand1 = random.nextInt(5 - 1 + 1) + 1;
if (rand1 == 1) {
shelterStability = 0;
setShelterStability();
addString("While you sleep, your unstable shelter collapses and you die.");
sleep(2);
gameOver();
switchView();
}
else{
shelterStability = 0;
setShelterStability();
addString("While you slept, your unstable shelter collapsed, but you survived");
}
}
else{
addString("Your shelter starts to shake, but holds strong");
}
break;
case 3:

break;
case 4:

break;
case 5:

break;
default:

break;
}

}
}

public void foodChecker(int x){
if (intFood >= x)
{
intFood -= x;
setIntFood();
}
else
{
intFood = 0;
setIntFood();
}
}

public void hungerChecker(int x){
if (hunger >= x)
{
hunger -= x;
setHunger(hunger);
}
else
{
hunger = 0;
setHunger(hunger);
}
}

public void resourceChecker(int x){
if (intResources >= x)
{
intResources -= x;
setIntResources();
}
else
{
intResources = 0;
setIntResources();
}
}

public void gameOver(){
Intent intent = getIntent();
finish();
startActivity(intent);
}

public void switchView() {
startActivity(new Intent(MainActivity.this,GameOverActivity.class));
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}

<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=".MainActivity">

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="112dp"
android:layout_height="70dp"
android:text="Scavenge"
android:id="@+id/scavenge"
android:onClick="scavenge"
android:layout_marginTop="340dp"
android:layout_alignParentStart="true" />

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="112dp"
android:layout_height="70dp"
android:text="Hunt"
android:id="@+id/hunt"
android:onClick="hunt"
android:layout_alignTop="@+id/eat"
android:layout_alignStart="@+id/repair" />

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="112dp"
android:layout_height="70dp"
android:text="Eat"
android:id="@+id/eat"
android:layout_alignTop="@+id/scavenge"
android:layout_centerHorizontal="true"
android:gravity="center"
android:nestedScrollingEnabled="false"
android:onClick="eat" />

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="112dp"
android:layout_height="70dp"
android:text="Repair Shelter"
android:id="@+id/repair"
android:layout_below="@+id/hunt"
android:layout_alignParentEnd="true"
android:onClick="repairShelter" />

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="112dp"
android:layout_height="70dp"
android:text="Raid Someone"
android:id="@+id/raid"
android:layout_alignParentStart="true"
android:layout_alignTop="@+id/repair"
android:onClick="raidSomeone" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Day: 1 Time remaining: 24h"
android:id="@+id/timeRemaining"
android:singleLine="false"
android:layout_above="@+id/hunt"
android:layout_centerHorizontal="true"
android:layout_marginBottom="37dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Resources: "
android:id="@+id/resources"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Food: "
android:id="@+id/food"
android:layout_below="@+id/resources"
android:layout_alignParentStart="true" />

<Button
android:layout_width="112dp"
android:layout_height="70dp"
android:text="Sleep"
android:id="@+id/button2"
android:onClick="sleepButton"
android:layout_below="@+id/scavenge"
android:layout_alignStart="@+id/eat" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Shelter Stability:"
android:id="@+id/shelter"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Energy:"
android:id="@+id/energy"
android:layout_below="@+id/shelter"
android:layout_alignEnd="@+id/shelter" />

<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView"
android:nestedScrollingEnabled="false"
android:stackFromBottom="true"
android:scrollingCache="false"
android:smoothScrollbar="false"
android:layout_alignTop="@+id/scrollView"
android:layout_alignBottom="@+id/scrollView" />

<ScrollView
android:layout_width="200dp"
android:layout_height="300dp"
android:id="@+id/scrollView"
android:fillViewport="false"
android:layout_below="@+id/food"
android:layout_marginBottom="240dp"
android:layout_alignParentStart="true"
android:layout_alignEnd="@+id/energy">

</ScrollView>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Full"
android:id="@+id/hunger"
android:layout_centerHorizontal="true"
android:layout_marginTop="311dp"
android:textColor="#ff000000"
android:textSize="20dp" />

</RelativeLayout>

Sorry about posting the code, just have no idea what to do [MENTION=6754410]mmdeveloper10[/MENTION]