Last active
September 21, 2017 03:14
-
-
Save Butch78/cbebc2c6ff3497eb63badbd3f5191b46 to your computer and use it in GitHub Desktop.
ImageViewApp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout 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.matthew.imagebrowserapp.MainActivity"> | |
<LinearLayout | |
android:layout_width="wrap_content" | |
android:layout_height="0dp" | |
android:orientation="horizontal" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintLeft_toLeftOf="parent" | |
app:layout_constraintRight_toRightOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
tools:layout_constraintBottom_creator="1" | |
tools:layout_constraintLeft_creator="1" | |
tools:layout_constraintRight_creator="1" | |
tools:layout_constraintTop_creator="1"> | |
<TableLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:stretchColumns="*" | |
android:layout_weight="1.0"> | |
<TableRow | |
android:layout_width="wrap_content" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
android:layout_weight="0.25"> | |
<ImageView | |
android:id="@+id/imageView" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:srcCompat="@mipmap/rav1" /> | |
</TableRow> | |
<TableRow | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_weight="0.25"> | |
<ImageView | |
android:id="@+id/imageView2" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:srcCompat="@mipmap/rav2" /> | |
</TableRow> | |
<TableRow | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_weight="0.25"> | |
<ImageView | |
android:id="@+id/imageView3" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:srcCompat="@mipmap/rav3" /> | |
</TableRow> | |
<TableRow | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_weight="0.25"> | |
<ImageView | |
android:id="@+id/imageView4" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:srcCompat="@mipmap/rav4" /> | |
</TableRow> | |
</TableLayout> | |
</LinearLayout> | |
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.matthew.imagebrowserapp; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.design.widget.FloatingActionButton; | |
import android.support.design.widget.Snackbar; | |
import android.support.v7.app.AppCompatActivity; | |
import android.support.v7.widget.Toolbar; | |
import android.view.View; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
public class Main2Activity extends AppCompatActivity { | |
ImageView imgv; | |
TextView textv; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main2); | |
imgv = (ImageView) findViewById(R.id.imageView5); | |
textv = (TextView) findViewById(R.id.textView); | |
Intent iImage = getIntent(); | |
int rImage = iImage.getExtras().getInt("IMAGE"); | |
imgv.setImageResource(rImage); | |
Intent iText = getIntent(); | |
int rText = iText.getExtras().getInt("TEXT"); | |
textv.setText(rText); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.matthew.imagebrowserapp; | |
import android.content.Intent; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.ImageView; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
initializeUI(); | |
} | |
private void initializeUI() | |
{ | |
ImageView pictureOne = (ImageView) findViewById(R.id.imageView); | |
ImageView pictureTwo = (ImageView) findViewById(R.id.imageView2); | |
ImageView pictureThree = (ImageView) findViewById(R.id.imageView3); | |
ImageView pictureFour = (ImageView) findViewById(R.id.imageView4); | |
pictureOne.setOnClickListener(new View.OnClickListener(){ | |
public void onClick(View v){ | |
Intent ravIntent = new Intent(); | |
ravIntent.setClass(getApplicationContext(), Main2Activity.class); | |
ravIntent.putExtra("IMAGE", R.drawable.rav1); | |
ravIntent.putExtra("TEXT", R.string.ravioli_in_a_round_shape); | |
startActivity(ravIntent); | |
} | |
}); | |
pictureTwo.setOnClickListener(new View.OnClickListener(){ | |
public void onClick(View v){ | |
Intent ravIntent = new Intent(); | |
ravIntent.setClass(getApplicationContext(), Main2Activity.class); | |
ravIntent.putExtra("IMAGE", R.drawable.rav2); | |
ravIntent.putExtra("TEXT", R.string.ravioli_with_tomato_sauce); | |
startActivity(ravIntent); | |
} | |
}); | |
pictureThree.setOnClickListener(new View.OnClickListener(){ | |
public void onClick(View v){ | |
Intent ravIntent = new Intent(); | |
ravIntent.setClass(getApplicationContext(), Main2Activity.class); | |
ravIntent.putExtra("IMAGE", R.drawable.rav3); | |
ravIntent.putExtra("TEXT", R.string.ravioli_pasta_bake); | |
startActivity(ravIntent); | |
} | |
}); | |
pictureFour.setOnClickListener(new View.OnClickListener(){ | |
public void onClick(View v){ | |
Intent ravIntent = new Intent(); | |
ravIntent.setClass(getApplicationContext(), Main2Activity.class); | |
ravIntent.putExtra("IMAGE", R.drawable.rav4); | |
ravIntent.putExtra("TEXT", R.string.ravioli_being_made); | |
startActivity(ravIntent); | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
<!-- Customize your theme here. --> | |
<item name="colorPrimary">@color/colorPrimary</item> | |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |
<item name="colorAccent">@color/colorAccent</item> | |
</style> | |
<style name="AppTheme.NoActionBar"> | |
<item name="windowActionBar">false</item> | |
<item name="windowNoTitle">true</item> | |
</style> | |
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> | |
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment