HeavyMetalsDetailsActivity.java
|
package de.anna.cellfreestick;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;
//Screen that shows you details about the different analytes
public class HeavyMetalsDetailsActivity extends ActionBarActivity {
//Declaration of variables
String title;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_heavy_metals_details);
//find View elements
title = getIntent().getStringExtra("value_title");
TextView titleHeavyMetals = (TextView) findViewById(R.id.titleHeavyMetal);
titleHeavyMetals.setText(title);
TextView textHeavyMetals = (TextView) findViewById(R.id.textHeavyMetal);
textHeavyMetals.setText(addText(title));
}
//Adds text to the view depending on the title
private String addText(String title) {
String mTitle;
switch (title) {
case "Arsenic":
mTitle = getResources().getString(R.string.Arsenic);
break;
case "Date rape drugs":
mTitle = getResources().getString(R.string.date_rape_drugs);
break;
case "Mercury":
mTitle = getResources().getString(R.string.Mercury);
break;
case "Chromium":
mTitle = getResources().getString(R.string.Chromium);
break;
case "Lead":
mTitle = getResources().getString(R.string.Lead);
break;
case "Nickel":
mTitle = getResources().getString(R.string.Nickel);
break;
case "Copper":
mTitle = getResources().getString(R.string.Copper);
break;
default:
mTitle = "you did not click an valid item!";
break;
}
return mTitle;
}
@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_heavy_metals_details, 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);
}
}