Skip to content

Commit

Permalink
image add button added
Browse files Browse the repository at this point in the history
  • Loading branch information
1405043-kd committed Jun 3, 2017
1 parent bc97c18 commit 2dd1f10
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 16 deletions.
4 changes: 3 additions & 1 deletion ToLet/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.tolet">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
30 changes: 30 additions & 0 deletions ToLet/app/src/main/java/com/example/user/tolet/PostAdd.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package com.example.user.tolet;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;

import static com.example.user.tolet.R.layout.activity_main;

public class PostAdd extends AppCompatActivity {
public static final int RESULT_LOAD_IMAGE=1;
public static final String EXTRA_MESSAGE = "com.example.user.tolet";
EditText editText1;
EditText editText2;
Expand All @@ -24,6 +30,9 @@ public class PostAdd extends AppCompatActivity {
Button imb;
Switch aSwitch;
ImageButton imageButton;
ImageView imageView;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -37,8 +46,29 @@ protected void onCreate(Bundle savedInstanceState) {
textView=(TextView) findViewById(R.id.currState);
imb=(Button)findViewById(R.id.postButton);
aSwitch=(Switch) findViewById(R.id.switcha);
imageButton=(ImageButton) findViewById(R.id.imageButtonPic);
imageView=(ImageView)findViewById(R.id.imageView);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent galleryIntent =new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent,RESULT_LOAD_IMAGE);
}
});

}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==RESULT_LOAD_IMAGE && resultCode==RESULT_OK && data!=null){
Uri selectedImage=data.getData();
imageView.setImageURI(selectedImage);
// Bitmap bitmap=(BitmapDrawable) imageView.getDrawable().getBitMap();

}
}


public void sendMessage(View view) {
Intent intent = new Intent(this, MainActivity.class);
EditText editText = (EditText) findViewById(R.id.houseNO);
Expand Down
30 changes: 15 additions & 15 deletions ToLet/app/src/main/res/layout/activity_ad_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,6 @@
android:layout_height="match_parent"
tools:context="com.example.user.tolet.AdPage">

<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">

<TextView
android:id="@+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>

<LinearLayout
android:layout_width="458dp"
android:layout_height="495dp"
Expand Down Expand Up @@ -48,4 +33,19 @@

</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">

<TextView
android:id="@+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>

</android.support.constraint.ConstraintLayout>
7 changes: 7 additions & 0 deletions ToLet/app/src/main/res/layout/activity_post_add.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@
android:layout_weight="1"
android:orientation="horizontal">

<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@android:drawable/ic_btn_speak_now" />

<TextView
android:id="@+id/currState"
android:layout_width="wrap_content"
Expand Down

0 comments on commit 2dd1f10

Please sign in to comment.