Last active
November 15, 2022 12:03
-
-
Save rjlutz/95b4952310a790493dc68208b83a877e to your computer and use it in GitHub Desktop.
homework help
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"> | |
<EditText | |
android:id="@+id/etInput" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginStart="16dp" | |
android:layout_marginTop="8dp" | |
android:layout_marginEnd="16dp" | |
android:inputType="" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent"> | |
<requestFocus /> | |
</EditText> | |
</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
import android.app.Dialog; | |
import android.app.DialogFragment; | |
import android.content.Context; | |
import android.content.DialogInterface; | |
import android.os.Bundle; | |
import android.support.v7.app.AlertDialog; | |
import android.text.Editable; | |
import android.text.TextWatcher; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.widget.EditText; | |
public class AddNotationDialogFragment extends DialogFragment { | |
public interface AddNotationDialogListener { | |
void onFinishAddNotationDialog(String inputText); | |
} | |
private AddNotationDialogListener mListener; | |
private EditText mEditText; | |
private AlertDialog dialog; | |
@Override | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
LayoutInflater inflater = getActivity().getLayoutInflater(); | |
View view = inflater.inflate(R.layout.add_notation, null); | |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | |
builder.setTitle(R.string.enter_new_notation); | |
builder.setView(view); //This layout contains only two EditText, ET1 and ET2. | |
mEditText = view.findViewById(R.id.etInput); | |
mEditText.addTextChangedListener(new TextWatcher() { | |
@Override | |
public void beforeTextChanged(CharSequence s, int start, int count, int after) { } | |
@Override | |
public void onTextChanged(CharSequence s, int start, int before, int count) { } | |
@Override | |
public void afterTextChanged(Editable s) { | |
boolean valid = DiceNotation.isValid(s.toString()); | |
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(valid); | |
} | |
}); | |
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int whichButton) { | |
AddNotationDialogListener activity = (AddNotationDialogListener) getActivity(); | |
activity.onFinishAddNotationDialog(mEditText.getText().toString()); | |
AddNotationDialogFragment.this.dismiss(); | |
} | |
}); | |
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int whichButton) { | |
AddNotationDialogFragment.this.dismiss(); | |
} | |
}); | |
dialog = builder.create(); | |
return dialog; | |
} | |
@Override | |
public void onAttach(Context context) { | |
super.onAttach(context); | |
mListener = (AddNotationDialogListener) getActivity(); | |
} | |
} |
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
// code snippets only | |
... | |
public class ItemListActivity extends AppCompatActivity | |
implements AddNotationDialogFragment.AddNotationDialogListener { | |
... | |
@Override | |
public void onFinishAddNotationDialog(String id) { | |
DummyContent.addItem(new DummyContent.DummyItem(id,"",id)); | |
adapter.notifyItemInserted(adapter.getItemCount()-1); | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello. I think I know who can help you. Recently I was looking for someone to help me with geography homework help, and I found an interesting service that helps with programming and other types of homework. Therefore, I advise you to contact them if no one here helps.