Created
April 23, 2018 03:05
-
-
Save Jabriko/b25ea610e85399f0a4467528d0535890 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 id.indrasudirman.tablayoutwithfab; | |
| import android.content.DialogInterface; | |
| import android.os.Bundle; | |
| import android.support.v4.app.Fragment; | |
| import android.support.v7.app.AlertDialog; | |
| import android.text.SpannableString; | |
| import android.text.method.LinkMovementMethod; | |
| import android.text.style.ClickableSpan; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import android.widget.TextView; | |
| import android.widget.Toast; | |
| /** | |
| * A simple {@link Fragment} subclass. | |
| */ | |
| public class OneFragment extends Fragment { | |
| ClickableSpan clickableSpan; | |
| public OneFragment() { | |
| // Required empty public constructor | |
| } | |
| @Override | |
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
| Bundle savedInstanceState) { | |
| // Inflate the layout for this fragment | |
| View rootView = inflater.inflate(R.layout.fragment_one, container, false); | |
| final TextView textView = rootView.findViewById(R.id.textView_simple_past_explain); | |
| final SpannableString spannableString = new SpannableString("Simple Past Tense digunakan untuk menyatakan kejadian yang sudah selesai dan tidak ada hubungan sama sekali dengan saat ini (sekarang), biasanya hanya untuk menceritakan kejadian yang lalu saja. Simple Past Tense juga biasa digunakan untuk menyatakan sesuatu yang sudah terjadi dalam cerita."); | |
| clickableSpan = new ClickableSpan() { | |
| @Override | |
| public void onClick(View view) { | |
| AlertDialog.Builder alertDialogBuider = new AlertDialog.Builder(getActivity()); | |
| //set title | |
| alertDialogBuider | |
| .setTitle("Info"); | |
| alertDialogBuider | |
| .setMessage("Simple Past Tense adalah salah satu dari 14 Tense (waktu) yang ada dalam Grammar Bahasa Inggris") | |
| .setCancelable(false) | |
| .setIcon(R.drawable.info) | |
| .setPositiveButton("Sudah paham", new DialogInterface.OnClickListener() { | |
| @Override | |
| public void onClick(DialogInterface dialogInterface, int i) { | |
| dialogInterface.cancel(); | |
| Toast.makeText(getActivity(), "Saya sudah paham", Toast.LENGTH_SHORT).show(); | |
| } | |
| }); | |
| AlertDialog alertDialog = alertDialogBuider.create(); | |
| alertDialog.show(); | |
| spannableString.setSpan(clickableSpan,0,17,0); | |
| textView.setMovementMethod(LinkMovementMethod.getInstance()); | |
| textView.setText(spannableString); | |
| } | |
| }; | |
| return rootView; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment