Skip to content

Instantly share code, notes, and snippets.

View mitchtabian's full-sized avatar
🎞️
Building stuff

Mitch Tabian mitchtabian

🎞️
Building stuff
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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="codingwithmitch.com.dialogfragmentactivity.MainActivity">
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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="codingwithmitch.com.dialogfragmentactivity.MainActivity"
>
package codingwithmitch.com.dialogfragmentactivity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements MyCustomDialog.OnInputListener {
package codingwithmitch.com.dialogfragmentactivity;
import android.app.DialogFragment;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public interface OnInputListener{
void sendInput(String input);
}
public OnInputListener mOnInputListener;
@Override
public void onAttach(Context context) {
super.onAttach(context);
try{
mOnInputListener = (OnInputListener) getActivity();
}catch (ClassCastException e){
Log.e(TAG, "onAttach: ClassCastException: " + e.getMessage() );
}
}
mOnInputListener.sendInput(input);
getDialog().dismiss();
public class MainActivity extends AppCompatActivity implements MyCustomDialog.OnInputListener {
private static final String TAG = "MainActivity";
@Override
public void sendInput(String input) {
Log.d(TAG, "sendInput: got the input: " + input);
mInputDisplay.setText(input);
}
<?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="codingwithmitch.com.dialogfragmentfragment.MainActivity">
<FrameLayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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="codingwithmitch.com.dialogfragmentfragment.MainActivity">
<TextView