kandi background
Explore Kits

Spannable | Android image spannable on multi autocomplete text view

 by   krishnalalstha Java Version: Current License: No License

 by   krishnalalstha Java Version: Current License: No License

Download this library from

kandi X-RAY | Spannable Summary

Spannable is a Java library. Spannable has no bugs, it has no vulnerabilities and it has low support. However Spannable build file is not available. You can download it from GitHub.
Android image spannable on multi autocomplete text view. This project is released under MIT License.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • Spannable has a low active ecosystem.
  • It has 36 star(s) with 21 fork(s). There are 4 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 3 open issues and 3 have been closed. On average issues are closed in 18 days. There are 1 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of Spannable is current.
Spannable Support
Best in #Java
Average in #Java
Spannable Support
Best in #Java
Average in #Java

quality kandi Quality

  • Spannable has 0 bugs and 0 code smells.
Spannable Quality
Best in #Java
Average in #Java
Spannable Quality
Best in #Java
Average in #Java

securitySecurity

  • Spannable has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • Spannable code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
Spannable Security
Best in #Java
Average in #Java
Spannable Security
Best in #Java
Average in #Java

license License

  • Spannable does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.
Spannable License
Best in #Java
Average in #Java
Spannable License
Best in #Java
Average in #Java

buildReuse

  • Spannable releases are not available. You will need to build from source code and install.
  • Spannable has no build file. You will be need to create the build yourself to build the component from source.
Spannable Reuse
Best in #Java
Average in #Java
Spannable Reuse
Best in #Java
Average in #Java
Top functions reviewed by kandi - BETA

kandi has reviewed Spannable and discovered the below as its top functions. This is intended to give you an instant insight into Spannable implemented functionality, and help decide if they suit your requirements.

  • Adds the text to the Spannable .
    • Returns a filter that contains the contacts .
      • Delete string .
        • Get all contacts .
          • initialize the TextView
            • Set view at a specific position .
              • Extract a bitmap from a TextView
                • Set up the phone number .
                  • Sets the contact list .

                    Get all kandi verified functions for this library.

                    Get all kandi verified functions for this library.

                    Spannable Key Features

                    Android image spannable on multi autocomplete text view

                    how to make ellipsized text with rules character more than 65 in android?

                    copy iconCopydownload iconDownload
                    android:maxLength="65" 
                    android:ellipsize="end"
                    android:maxLines="1"
                    

                    Auto Scrollable Text View in Kotlin

                    copy iconCopydownload iconDownload
                    <HorizontalScrollView......
                       <TextView.......
                       </TextView......
                    </HorizontalScrollView>
                    
                    <EditText
                            android:id="@+id/tv_equation"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="end"
                            android:layout_marginTop="8dp"
                            android:inputType="text"
                            android:maxLines="1"
                            android:minLines="1"
                            android:isScrollContainer="true"
                            android:padding="5dp"
                            android:paddingStart="20dp"
                            android:paddingEnd="20dp"
                            android:text="@string/tv_equation"
                            android:textAlignment="textEnd"
                            android:textColor="@color/white"
                            android:textSize="45sp"
                            app:layout_constraintEnd_toEndOf="parent"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"/>
                    
                    binding.tv_equation.movementMethod = ScrollingMovementMethod() 
                    
                    EditText tv_equation = (EditText)findViewById(R.id.tv_equation); 
                    tv_equation.setMovementMethod(new ScrollingMovementMethod());
                    
                    <HorizontalScrollView......
                       <TextView.......
                       </TextView......
                    </HorizontalScrollView>
                    
                    <EditText
                            android:id="@+id/tv_equation"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="end"
                            android:layout_marginTop="8dp"
                            android:inputType="text"
                            android:maxLines="1"
                            android:minLines="1"
                            android:isScrollContainer="true"
                            android:padding="5dp"
                            android:paddingStart="20dp"
                            android:paddingEnd="20dp"
                            android:text="@string/tv_equation"
                            android:textAlignment="textEnd"
                            android:textColor="@color/white"
                            android:textSize="45sp"
                            app:layout_constraintEnd_toEndOf="parent"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"/>
                    
                    binding.tv_equation.movementMethod = ScrollingMovementMethod() 
                    
                    EditText tv_equation = (EditText)findViewById(R.id.tv_equation); 
                    tv_equation.setMovementMethod(new ScrollingMovementMethod());
                    
                    <HorizontalScrollView......
                       <TextView.......
                       </TextView......
                    </HorizontalScrollView>
                    
                    <EditText
                            android:id="@+id/tv_equation"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="end"
                            android:layout_marginTop="8dp"
                            android:inputType="text"
                            android:maxLines="1"
                            android:minLines="1"
                            android:isScrollContainer="true"
                            android:padding="5dp"
                            android:paddingStart="20dp"
                            android:paddingEnd="20dp"
                            android:text="@string/tv_equation"
                            android:textAlignment="textEnd"
                            android:textColor="@color/white"
                            android:textSize="45sp"
                            app:layout_constraintEnd_toEndOf="parent"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"/>
                    
                    binding.tv_equation.movementMethod = ScrollingMovementMethod() 
                    
                    EditText tv_equation = (EditText)findViewById(R.id.tv_equation); 
                    tv_equation.setMovementMethod(new ScrollingMovementMethod());
                    
                    <HorizontalScrollView......
                       <TextView.......
                       </TextView......
                    </HorizontalScrollView>
                    
                    <EditText
                            android:id="@+id/tv_equation"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="end"
                            android:layout_marginTop="8dp"
                            android:inputType="text"
                            android:maxLines="1"
                            android:minLines="1"
                            android:isScrollContainer="true"
                            android:padding="5dp"
                            android:paddingStart="20dp"
                            android:paddingEnd="20dp"
                            android:text="@string/tv_equation"
                            android:textAlignment="textEnd"
                            android:textColor="@color/white"
                            android:textSize="45sp"
                            app:layout_constraintEnd_toEndOf="parent"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"/>
                    
                    binding.tv_equation.movementMethod = ScrollingMovementMethod() 
                    
                    EditText tv_equation = (EditText)findViewById(R.id.tv_equation); 
                    tv_equation.setMovementMethod(new ScrollingMovementMethod());
                    
                     <TextView
                          android:id = "@+id/text"
                          android:textSize = "20dp"
                          android:textAlignment = "center"
                          android:layout_width = "match_parent"
                          android:ellipsize = "marquee"
                          android:fadingEdge = "horizontal"
                          android:marqueeRepeatLimit = "marquee_forever"
                          android:scrollHorizontally = "true"
                          android:textColor = "#ff4500"
                          android:text = "Simple application that shows how to use marquee, with a long text"
                          android:layout_height = "wrap_content"
                          android:singleLine = "true" />
                    
                    text.setVisibility(View.GONE); 
                    editText.setVisibility(View.VISIBLE);
                    editText.setText(edititemname);
                    
                     <TextView
                          android:id = "@+id/text"
                          android:textSize = "20dp"
                          android:textAlignment = "center"
                          android:layout_width = "match_parent"
                          android:ellipsize = "marquee"
                          android:fadingEdge = "horizontal"
                          android:marqueeRepeatLimit = "marquee_forever"
                          android:scrollHorizontally = "true"
                          android:textColor = "#ff4500"
                          android:text = "Simple application that shows how to use marquee, with a long text"
                          android:layout_height = "wrap_content"
                          android:singleLine = "true" />
                    
                    text.setVisibility(View.GONE); 
                    editText.setVisibility(View.VISIBLE);
                    editText.setText(edititemname);
                    

                    SpannableStringBuilder , ClickSpan not working , clickspan to multiple strings android

                    copy iconCopydownload iconDownload
                    {
                                    bold {
                                        append("Terms and Conditions ")
                                    }
                    
                                    object :ClickableSpan(){
                                        override fun onClick(view: View) {
                                            showTermsAndConditions()
                                        }
                                    }
                                }
                    
                        inSpans(
                              object :ClickableSpan(){
                                override fun onClick(view: View) {
                                    showKeys()
                                }
                    
                    
                    override fun updateDrawState(ds: TextPaint) { //to remove line //from spannable string
                                              super.updateDrawState(ds)
                                              ds.isUnderlineText = false
                                          }
                            },
                    
                            ForegroundColorSpan(ContextCompat.getColor(binding.termAndCondtionLabel.context,R.color.red_daily_limit))
                        ){
                            bold {
                                append("Key Fact Statement ")
                            }
                        }
                    
                    {
                                    bold {
                                        append("Terms and Conditions ")
                                    }
                    
                                    object :ClickableSpan(){
                                        override fun onClick(view: View) {
                                            showTermsAndConditions()
                                        }
                                    }
                                }
                    
                        inSpans(
                              object :ClickableSpan(){
                                override fun onClick(view: View) {
                                    showKeys()
                                }
                    
                    
                    override fun updateDrawState(ds: TextPaint) { //to remove line //from spannable string
                                              super.updateDrawState(ds)
                                              ds.isUnderlineText = false
                                          }
                            },
                    
                            ForegroundColorSpan(ContextCompat.getColor(binding.termAndCondtionLabel.context,R.color.red_daily_limit))
                        ){
                            bold {
                                append("Key Fact Statement ")
                            }
                        }
                    

                    How to bold title in notification?

                    copy iconCopydownload iconDownload
                    val title = "Awesome Title!"
                    val titleBold: Spannable = SpannableString(title)
                    sb.setSpan(StyleSpan(Typeface.BOLD), 0, title.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
                    
                    // ...
                    notificationBuilder.setContentTitle(titleBold)
                    // ...
                    

                    Android get ArrayList from Room Database in adapter class

                    copy iconCopydownload iconDownload
                    implementation 'com.google.code.gson:gson:2.8.6'
                    
                    SharedPreferences sharedPreferences = requireActivity().getSharedPreferences("shared_preferences", MODE_PRIVATE);
                                SharedPreferences.Editor editor = sharedPreferences.edit();
                    
                                Gson gson = new Gson();
                                String json = gson.toJson(myListOfData);
                                editor.putString("partsKEY", json);
                                editor.apply();
                    
                    SharedPreferences sharedPreferences = context.getSharedPreferences("shared_preferences", MODE_PRIVATE);
                            Gson gson = new Gson();
                            String json = sharedPreferences.getString("partsKEY", null);
                            Type type = new TypeToken<ArrayList<NoteTupleTest>>() {
                            }.getType();
                            partsArrayList= gson.fromJson(json, type);
                            if (partsArrayList== null) {
                                partsArrayList= new ArrayList<>();
                            }
                    
                    implementation 'com.google.code.gson:gson:2.8.6'
                    
                    SharedPreferences sharedPreferences = requireActivity().getSharedPreferences("shared_preferences", MODE_PRIVATE);
                                SharedPreferences.Editor editor = sharedPreferences.edit();
                    
                                Gson gson = new Gson();
                                String json = gson.toJson(myListOfData);
                                editor.putString("partsKEY", json);
                                editor.apply();
                    
                    SharedPreferences sharedPreferences = context.getSharedPreferences("shared_preferences", MODE_PRIVATE);
                            Gson gson = new Gson();
                            String json = sharedPreferences.getString("partsKEY", null);
                            Type type = new TypeToken<ArrayList<NoteTupleTest>>() {
                            }.getType();
                            partsArrayList= gson.fromJson(json, type);
                            if (partsArrayList== null) {
                                partsArrayList= new ArrayList<>();
                            }
                    
                    implementation 'com.google.code.gson:gson:2.8.6'
                    
                    SharedPreferences sharedPreferences = requireActivity().getSharedPreferences("shared_preferences", MODE_PRIVATE);
                                SharedPreferences.Editor editor = sharedPreferences.edit();
                    
                                Gson gson = new Gson();
                                String json = gson.toJson(myListOfData);
                                editor.putString("partsKEY", json);
                                editor.apply();
                    
                    SharedPreferences sharedPreferences = context.getSharedPreferences("shared_preferences", MODE_PRIVATE);
                            Gson gson = new Gson();
                            String json = sharedPreferences.getString("partsKEY", null);
                            Type type = new TypeToken<ArrayList<NoteTupleTest>>() {
                            }.getType();
                            partsArrayList= gson.fromJson(json, type);
                            if (partsArrayList== null) {
                                partsArrayList= new ArrayList<>();
                            }
                    

                    how to insert Image from gallery to a EditTex View?

                    copy iconCopydownload iconDownload
                    import androidx.appcompat.app.AppCompatActivity;
                    
                    import android.app.Activity;
                    import android.content.Intent;
                    import android.graphics.Bitmap;
                    import android.net.Uri;
                    import android.os.Bundle;
                    import android.provider.MediaStore;
                    import android.text.Spannable;
                    import android.text.SpannableStringBuilder;
                    import android.text.style.ImageSpan;
                    import android.util.Log;
                    import android.view.View;
                    import android.widget.ImageView;
                    import android.widget.LinearLayout;
                    import android.widget.TextView;
                    
                    import java.io.IOException;
                    
                    public class TestImage extends AppCompatActivity {
                    
                        ImageView img;
                        TextView textView;
                        private static final int PICK_IMAGE_REQUEST = 1;
                        private Uri filePath;
                        private Bitmap bitmap;
                    
                    
                        @Override
                        protected void onCreate(Bundle savedInstanceState) {
                            super.onCreate(savedInstanceState);
                            setContentView(R.layout.activity_test_image);
                    
                            img = findViewById(R.id.addImage);
                            textView = findViewById(R.id.textview);
                            img.setOnClickListener(new View.OnClickListener() {
                    
                                @Override
                                public void onClick(View view) {
                                    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                                    if (getApplicationContext() != null && getApplicationContext().getPackageName().equals(BuildConfig.APPLICATION_ID)){
                                        startActivityForResult(intent, PICK_IMAGE_REQUEST);
                                    }
                                }
                            });
                        }
                        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                            super.onActivityResult(requestCode, resultCode, data);
                            try {
                                switch (requestCode) {
                    
                                    case PICK_IMAGE_REQUEST:
                                        if (resultCode == Activity.RESULT_OK) {
                                            //data gives you the image uri. Try to convert that to bitmap
                                            filePath = data.getData();
                                            try {
                                                bitmap = MediaStore.Images.Media.getBitmap(TestImage.this.getContentResolver(), filePath);
                                                img.setImageBitmap(bitmap);
                    
                    
                                            } catch (IOException e) {
                                                e.printStackTrace();
                                            }
                                            break;
                                        } else if (resultCode == Activity.RESULT_CANCELED) {
                                            Log.e("TestImage", "Selecting picture cancelled");
                                        }
                                        break;
                                }
                            } catch (Exception e) {
                                Log.e("TestImage", "Exception in onActivityResult : " + e.getMessage());
                            }
                        }
                    }
                    
                    <?xml version="1.0" encoding="utf-8"?>
                    <LinearLayout
                    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=".TestImage"
                    android:orientation="vertical">
                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="250sp"
                        android:src="@mipmap/ic_launcher"
                        android:id="@+id/addImage"/>
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="Here is your text"
                        android:textSize="50sp"
                        android:id="@+id/textview"/>
                     </LinearLayout>
                    
                    import androidx.appcompat.app.AppCompatActivity;
                    
                    import android.app.Activity;
                    import android.content.Intent;
                    import android.graphics.Bitmap;
                    import android.net.Uri;
                    import android.os.Bundle;
                    import android.provider.MediaStore;
                    import android.text.Spannable;
                    import android.text.SpannableStringBuilder;
                    import android.text.style.ImageSpan;
                    import android.util.Log;
                    import android.view.View;
                    import android.widget.ImageView;
                    import android.widget.LinearLayout;
                    import android.widget.TextView;
                    
                    import java.io.IOException;
                    
                    public class TestImage extends AppCompatActivity {
                    
                        ImageView img;
                        TextView textView;
                        private static final int PICK_IMAGE_REQUEST = 1;
                        private Uri filePath;
                        private Bitmap bitmap;
                    
                    
                        @Override
                        protected void onCreate(Bundle savedInstanceState) {
                            super.onCreate(savedInstanceState);
                            setContentView(R.layout.activity_test_image);
                    
                            img = findViewById(R.id.addImage);
                            textView = findViewById(R.id.textview);
                            img.setOnClickListener(new View.OnClickListener() {
                    
                                @Override
                                public void onClick(View view) {
                                    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                                    if (getApplicationContext() != null && getApplicationContext().getPackageName().equals(BuildConfig.APPLICATION_ID)){
                                        startActivityForResult(intent, PICK_IMAGE_REQUEST);
                                    }
                                }
                            });
                        }
                        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                            super.onActivityResult(requestCode, resultCode, data);
                            try {
                                switch (requestCode) {
                    
                                    case PICK_IMAGE_REQUEST:
                                        if (resultCode == Activity.RESULT_OK) {
                                            //data gives you the image uri. Try to convert that to bitmap
                                            filePath = data.getData();
                                            try {
                                                bitmap = MediaStore.Images.Media.getBitmap(TestImage.this.getContentResolver(), filePath);
                                                img.setImageBitmap(bitmap);
                    
                    
                                            } catch (IOException e) {
                                                e.printStackTrace();
                                            }
                                            break;
                                        } else if (resultCode == Activity.RESULT_CANCELED) {
                                            Log.e("TestImage", "Selecting picture cancelled");
                                        }
                                        break;
                                }
                            } catch (Exception e) {
                                Log.e("TestImage", "Exception in onActivityResult : " + e.getMessage());
                            }
                        }
                    }
                    
                    <?xml version="1.0" encoding="utf-8"?>
                    <LinearLayout
                    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=".TestImage"
                    android:orientation="vertical">
                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="250sp"
                        android:src="@mipmap/ic_launcher"
                        android:id="@+id/addImage"/>
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="Here is your text"
                        android:textSize="50sp"
                        android:id="@+id/textview"/>
                     </LinearLayout>
                    

                    Keeping 2D interpolation within shape

                    copy iconCopydownload iconDownload
                    import matplotlib.pyplot as plt
                    import numpy as np
                    import pandas as pd
                    from scipy.interpolate import griddata
                    import matplotlib.path as mpath
                    
                    import alphashape
                    from descartes import PolygonPatch
                    
                    Path = mpath.Path
                    
                    data = pd.DataFrame({
                        'time': [0, 1, 2, 3, 4, 0.1, 0.9, 2, 3.05, 4, 0, 1, 2.2, 3, 3.95],
                        'force': [1, 2, 4, 9, 16, 0, 0, 0, 0, 0, -1, -2, -4, -9, -16]
                    })
                    
                    Times, Forces = np.meshgrid(
                        np.linspace(0, 4, 100),
                        np.linspace(-16, 16, 100)
                    )
                    
                    data['work'] = data['time'] * data['force']
                    
                    interpolation = griddata(
                        (data['time'], data['force']),
                        data['work'],
                        (Times, Forces),
                        method= 'linear')
                    
                    fig, ax = plt.subplots()
                    plt.xlim(-.3,4.3)
                    plt.ylim(-18,18)
                    
                    #contour = ax.contourf( Times, Forces, interpolation)
                    contour = ax.tricontourf( data['time'], data['force'], data['work'])
                    ax.scatter(data['time'], data['force'])
                    
                    
                    x = data['time']
                    y =  data['force']
                    
                    points = np.vstack([x, y]).T
                    alpha = 0.95 * alphashape.optimizealpha(points)
                    hull = alphashape.alphashape(points, alpha)
                    hull_pts = hull.exterior.coords.xy
                    
                    ax.scatter(hull_pts[0], hull_pts[1], color='red')
                    ax.add_patch(PolygonPatch(hull, fill=False, color='red'))
                    
                    plt.savefig("clip_before.png")
                    #make clip path
                    vertices = []
                    codes = []
                    xpts,ypts = hull_pts
                    
                    ## convert polygon to path for cliping contour fill
                    for ix,iy in zip(xpts,ypts):
                        vertices.append((ix,iy))
                    codes += [Path.MOVETO]
                    codes += [Path.LINETO] * (len(xpts) -2)
                    codes += [Path.CLOSEPOLY]
                    clip = Path(vertices, codes)
                    
                    for collection in contour.collections:
                        collection.set_clip_path(clip,transform=ax.transData)
                    plt.savefig("clip_after.png")
                    plt.show()
                    

                    onCreateOptionsMenu showing alwasy as action with a menu that i have created programatically

                    copy iconCopydownload iconDownload
                    @Override
                    public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
                            super.onCreateOptionsMenu(menu, inflater);
                    
                    
                    MenuItem menuItem =  menu.add(0, 0, 0, new SetUpClass().menuInitializer(
                         Objects.requireNonNull(ContextCompat.getDrawable(requireActivity(),R.drawable.ic_cart)),
                                    getResources().getString(R.string.cart)));
                    menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
                    
                    
                    }
                    

                    How to search a SpannableString without knowing the exact substring

                    copy iconCopydownload iconDownload
                    public class Main
                    {
                        public static void main(String[] args)
                        {
                            String str = "string [size=212] more string [size=212] more string here";
                            Pattern pat = Pattern.compile("\\[size=[0-9]+\\]");
                            Matcher mat = pat.matcher(str);
                    
                            int index, lastIndex = 0, length, value;
                    
                            while(mat.find()) {
                                final String found = mat.group(0);
                                value = Integer.parseInt(found.replaceAll("^\\[size=|\\]$", ""));
                                length = found.length();
                                index = str.indexOf(found, lastIndex);
                                lastIndex += length;
                    
                                System.out.printf("index: %d, length: %d, string: %s, value: %d%n", index, length, found, value);
                            }
                        }
                    }
                    
                    index: 7, length: 10, string: [size=212], value: 212
                    index: 30, length: 10, string: [size=212], value: 212
                    
                    public class Main
                    {
                        public static void main(String[] args)
                        {
                            String str = "string [size=212] more string [size=212] more string here";
                            Pattern pat = Pattern.compile("\\[size=[0-9]+\\]");
                            Matcher mat = pat.matcher(str);
                    
                            int index, lastIndex = 0, length, value;
                    
                            while(mat.find()) {
                                final String found = mat.group(0);
                                value = Integer.parseInt(found.replaceAll("^\\[size=|\\]$", ""));
                                length = found.length();
                                index = str.indexOf(found, lastIndex);
                                lastIndex += length;
                    
                                System.out.printf("index: %d, length: %d, string: %s, value: %d%n", index, length, found, value);
                            }
                        }
                    }
                    
                    index: 7, length: 10, string: [size=212], value: 212
                    index: 30, length: 10, string: [size=212], value: 212
                    

                    Navigate up from activity to fragment open the same fragment - Android Navigation Component

                    copy iconCopydownload iconDownload
                    Fragment fragmentByTag = getFragmentManager().
                                        findFragmentByTag("Old fragment tag");
                                if (fragmentByTag != null) {
                                    getFragmentManager().beginTransaction()
                                            .remove(fragmentByTag).commit();
                                }
                    
                    public class DetailsFragment extends Fragment {
                    
                        private static final String TAG = "DetailsFragment";
                    
                        private FragmentDetailsBinding binding;
                    
                        String url, title, content, youtubeThumbnailImageSrc, youTubeLink;
                        int youtubeThumbnailImageSetVisibility;
                        private PostViewModel postViewModel;
                    
                        @Override
                        public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
                            super.onViewCreated(view, savedInstanceState);
                    
                            postViewModel = new ViewModelProvider(this).get(PostViewModel.class);
                            Log.d(TAG, "onCreate checkSavedFavoritesItems: " + postFavoritesSavedId);
                    
                    
                            postItem = DetailsFragmentArgs.fromBundle(getArguments()).getPostItem();
                    
                    
                            final Document document = Jsoup.parse(postItem.getContent());
                    //                    final Elements elements = document.select("img");
                    
                            Element element = document.body();
                    
                            for (Element e : element.getElementsByClass
                                    ("YOUTUBE-iframe-video")) {
                                youtubeThumbnailImageSrc = e.attr("data-thumbnail-src");
                                youTubeLink = e.attr("src");
                                Log.e("YouTube thumbnail", youtubeThumbnailImageSrc);
                                Log.e("Youtube link", youTubeLink);
                            }
                    
                            if (youtubeThumbnailImageSrc == null) {
                                youtubeThumbnailImageSetVisibility = 8;
                            }
                    
                            url = postItem.getUrl();
                            title = postItem.getTitle();
                            content = postItem.getContent();
                    
                    
                            //        blogImage = (ImageView) findViewById(R.id.blogImage);
                    
                            setHasOptionsMenu(true);
                    //        Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false);
                            Objects.requireNonNull( ((MainActivity) requireActivity())
                                    .getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
                    //        getSupportActionBar().setDisplayShowHomeEnabled(true);
                    
                            binding.progressBar.setVisibility(View.VISIBLE);
                    
                            binding.titleTextView.setText(title);
                            binding.blogContent.setMovementMethod(LinkMovementMethod.getInstance());
                    
                    
                            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                                binding.fab.bringToFront();
                            }
                    
                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                                binding.scrollView.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
                                    //   Log.d("ScrollView","scrollX_"+scrollX+"_scrollY_"+scrollY+"_oldScrollX_"+oldScrollX+"_oldScrollY_"+oldScrollY);
                                    if (scrollY > 0 && binding.fab.isShown()) {
                                        binding.fab.hide();
                                    } else if (scrollY < 22) {
                                        binding.fab.show();
                    
                                    }
                                });
                            } else {
                                binding.scrollView.getViewTreeObserver().addOnScrollChangedListener(() -> {
                                    int mScrollY = binding.scrollView.getScrollY();
                                    if (mScrollY > 0 && binding.fab.isShown()) {
                                        binding.fab.hide();
                                    } else if (mScrollY < 22) {
                                        binding.fab.show();
                                    }
                                });
                            }
                    
                    
                            binding.fab.setOnClickListener(view2 -> {
                                String shareContent = title + "\n" + url;
                                Intent shareIntent = new Intent(Intent.ACTION_SEND);
                                shareIntent.setType("text/plain");
                                shareIntent.putExtra(Intent.EXTRA_TEXT, shareContent);
                                shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    
                                try {
                                    startActivity(Intent.createChooser(shareIntent, title));
                                } catch (Exception exception) {
                                    Log.e(TAG, "onCreate: " + exception);
                                }
                            });
                    
                    
                            //       String imageSrc = getIntent().getStringExtra("blogImage");
                            //       Glide.with(getApplicationContext()).load(imageSrc).into(blogImage);
                    
                    
                            binding.youtubeThumbnailImage.setVisibility(youtubeThumbnailImageSetVisibility);
                            binding.youtubeThumbnailImage.setAdjustViewBounds(true);
                            Picasso.get().load(youtubeThumbnailImageSrc).into(binding.youtubeThumbnailImage);
                    
                            binding.youtubeThumbnailImage.setOnClickListener(view1 -> {
                                Intent youTube = new Intent
                                        (Intent.ACTION_VIEW, Uri.parse(youTubeLink));
                                startActivity(youTube);
                            });
                    
                    
                            PicassoImageGetter imageGetter = new PicassoImageGetter(binding.blogContent, requireContext());
                            Spannable html;
                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                                html = (Spannable) Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY, imageGetter, null);
                            } else {
                                html = (Spannable) Html.fromHtml(content, imageGetter, null);
                            }
                    
                            binding.blogContent.setText(html);
                    
                    
                            binding.visitSite.setOnClickListener(view3 -> openCustomTab(requireContext(), Uri.parse(url)));
                            binding.progressBar.setVisibility(View.GONE);
                        }
                    
                        private Item postItem;
                        private boolean postFavoritesSaved = false;
                        private int postFavoritesSavedId = 0;
                        private MenuItem menuItem;
                    
                        @Override
                        public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container,
                                                 Bundle savedInstanceState) {
                            // Inflate the layout for this fragment
                            binding =  FragmentDetailsBinding.inflate(inflater, container, false);
                            return binding.getRoot();
                        }
                    
                    
                        @Override
                        public void onCreateOptionsMenu(@NonNull Menu menu,
                                                        @NonNull MenuInflater inflater) {
                            super.onCreateOptionsMenu(menu, inflater);
                            inflater.inflate(R.menu.activity_details_menu, menu);
                            menuItem = menu.findItem(R.id.action_add_to_favorites);
                            checkSavedFavoritesItems(menuItem);
                        }
                    
                        @Override
                        public void onDestroyView() {
                            super.onDestroyView();
                            menuItem.setIcon(R.drawable.ic_favorite_border);
                        }
                    
                        private void checkSavedFavoritesItems(MenuItem menuItem) {
                            postViewModel.getAllFavorites().observe(this, favoritesEntity -> {
                                try {
                                    for (FavoritesEntity savedPost: favoritesEntity) {
                                        if (savedPost.getItem().getId().equals(postItem.getId())) {
                                            menuItem.setIcon(R.drawable.ic_favorite);
                                            postFavoritesSavedId = savedPost.getId();
                                            Log.d(TAG, "checkSavedFavoritesItems: " + postFavoritesSavedId);
                                            postFavoritesSaved = true;
                                        }
                                    }
                                } catch (Exception exception) {
                                    Log.e(TAG, "checkSavedFavoritesItems: " + exception.getMessage());
                                }
                            });
                        }
                    
                        @Override
                        public boolean onOptionsItemSelected(MenuItem menuItem) {
                    
                            if (menuItem.getItemId() == R.id.action_add_to_favorites && !postFavoritesSaved) {
                                saveTogFavorites(menuItem);
                            } else if (menuItem.getItemId() == R.id.action_add_to_favorites && postFavoritesSaved) {
                                removePostFromFavorites(menuItem);
                            } else if (menuItem.getItemId() == R.id.action_share) {
                                ShareActionProvider shareActionProvider =
                                        (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
                                shareActionProvider.setShareIntent(createShareIntent());
                                return true;
                            } else if (menuItem.getItemId() == R.id.copyTheLink) {
                                ClipboardManager clipboardManager = (ClipboardManager)
                                        requireActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                                ClipData clipData = ClipData.newPlainText("link", url);
                                assert clipboardManager != null;
                                clipboardManager.setPrimaryClip(clipData);
                                Toast.makeText(requireContext(), getString(R.string.linkCopied), Toast.LENGTH_LONG).show();
                                return true;
                            }
                    
                            return super.onOptionsItemSelected(menuItem);
                        }
                    
                        private void saveTogFavorites(MenuItem menuItem) {
                            FavoritesEntity favoritesEntity = new FavoritesEntity(0,
                                    postItem);
                    
                            postViewModel.insertFavorites(favoritesEntity);
                            menuItem.setIcon(R.drawable.ic_favorite);
                            Snackbar.make(binding.getRoot(), "Saved", Snackbar.LENGTH_LONG).show();
                            postFavoritesSaved = true;
                        }
                    
                    
                        private void removePostFromFavorites(MenuItem menuItem) {
                            FavoritesEntity favoritesEntity = new FavoritesEntity(postFavoritesSavedId,
                                    postItem);
                    
                            Log.d(TAG, "checkSavedFavoritesItems: " + postFavoritesSavedId);
                            postViewModel.deleteFavoritePost(favoritesEntity);
                            menuItem.setIcon(R.drawable.ic_favorite_border);
                            Snackbar.make(binding.getRoot(),
                                    "Post deleted from favorites", Snackbar.LENGTH_LONG).show();
                            postFavoritesSaved = false;
                        }
                    
                    <?xml version="1.0" encoding="utf-8"?>
                    <navigation 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:id="@+id/mobile_navigation"
                        app:startDestination="@id/nav_home">
                    
                        <fragment
                            android:id="@+id/nav_home"
                            android:name="com.blogspot.abtallaldigital.ui.home.HomeFragment"
                            android:label="@string/home"
                            tools:layout="@layout/fragment_home">
                            <action
                                android:id="@+id/action_nav_home_to_detailsFragment"
                                app:destination="@id/detailsFragment"
                                app:popUpTo="@id/nav_home" />
                        </fragment>
                    
                        <fragment
                            android:id="@+id/nav_Accessory"
                            android:name="com.blogspot.abtallaldigital.ui.accessory.AccessoryFragment"
                            android:label="@string/accessory"
                            tools:layout="@layout/fragment_accessory" >
                            <action
                                android:id="@+id/action_nav_Accessory_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                    
                        <fragment
                            android:id="@+id/nav_Arcade"
                            android:name="com.blogspot.abtallaldigital.ui.arcade.ArcadeFragment"
                            android:label="@string/arcade"
                            tools:layout="@layout/fragment_arcade" >
                            <action
                                android:id="@+id/action_nav_Arcade_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                    
                        <fragment
                            android:id="@+id/nav_Fashion"
                            android:name="com.blogspot.abtallaldigital.ui.fashion.FashionFragment"
                            android:label="@string/fashion"
                            tools:layout="@layout/fashion_fragment" >
                            <action
                                android:id="@+id/action_nav_Fashion_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Food"
                            android:name="com.blogspot.abtallaldigital.ui.food.FoodFragment"
                            android:label="@string/food"
                            tools:layout="@layout/food_fragment" >
                            <action
                                android:id="@+id/action_nav_Food_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Heath"
                            android:name="com.blogspot.abtallaldigital.ui.heath.HeathFragment"
                            android:label="@string/heath"
                            tools:layout="@layout/heath_fragment" >
                            <action
                                android:id="@+id/action_nav_Heath_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Lifestyle"
                            android:name="com.blogspot.abtallaldigital.ui.lifestyle.LifestyleFragment"
                            android:label="@string/lifestyle"
                            tools:layout="@layout/lifestyle_fragment" >
                            <action
                                android:id="@+id/action_nav_Lifestyle_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Sports"
                            android:name="com.blogspot.abtallaldigital.ui.sports.SportsFragment"
                            android:label="@string/sports"
                            tools:layout="@layout/sports_fragment" >
                            <action
                                android:id="@+id/action_nav_Sports_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <dialog
                            android:id="@+id/about"
                            android:name="com.blogspot.abtallaldigital.ui.about.AboutFragment"
                            android:label="about"
                            tools:layout="@layout/about" />
                        <fragment
                            android:id="@+id/detailsFragment"
                            android:name="com.blogspot.abtallaldigital.ui.DetailsFragment"
                            android:label="Post details"
                            tools:layout="@layout/fragment_details" >
                            <argument
                                android:name="postItem"
                                app:argType="com.blogspot.abtallaldigital.pojo.Item" />
                        </fragment>
                    </navigation>
                    
                    @Override
                        public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
                            super.onViewCreated(view, savedInstanceState);
                    
                            navController = Navigation.findNavController(requireView());
                    
                            binding.homeRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(requireContext(),
                                    binding.homeRecyclerView, new RecyclerItemClickListener.OnItemClickListener() {
                                @Override
                                public void onItemClick(View view, int position) {
                    
                                    Item item = itemArrayList.get(position);
                    
                                    if (Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.nav_home) {
                                        Navigation.findNavController(requireView())
                                                .navigate(HomeFragmentDirections.actionNavHomeToDetailsFragment(item));
                                    }
                    
                                }
                    
                                @Override
                                public void onLongItemClick(View view, int position) {
                    
                                }
                            }
                            ));
                        }
                    
                    public class DetailsFragment extends Fragment {
                    
                        private static final String TAG = "DetailsFragment";
                    
                        private FragmentDetailsBinding binding;
                    
                        String url, title, content, youtubeThumbnailImageSrc, youTubeLink;
                        int youtubeThumbnailImageSetVisibility;
                        private PostViewModel postViewModel;
                    
                        @Override
                        public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
                            super.onViewCreated(view, savedInstanceState);
                    
                            postViewModel = new ViewModelProvider(this).get(PostViewModel.class);
                            Log.d(TAG, "onCreate checkSavedFavoritesItems: " + postFavoritesSavedId);
                    
                    
                            postItem = DetailsFragmentArgs.fromBundle(getArguments()).getPostItem();
                    
                    
                            final Document document = Jsoup.parse(postItem.getContent());
                    //                    final Elements elements = document.select("img");
                    
                            Element element = document.body();
                    
                            for (Element e : element.getElementsByClass
                                    ("YOUTUBE-iframe-video")) {
                                youtubeThumbnailImageSrc = e.attr("data-thumbnail-src");
                                youTubeLink = e.attr("src");
                                Log.e("YouTube thumbnail", youtubeThumbnailImageSrc);
                                Log.e("Youtube link", youTubeLink);
                            }
                    
                            if (youtubeThumbnailImageSrc == null) {
                                youtubeThumbnailImageSetVisibility = 8;
                            }
                    
                            url = postItem.getUrl();
                            title = postItem.getTitle();
                            content = postItem.getContent();
                    
                    
                            //        blogImage = (ImageView) findViewById(R.id.blogImage);
                    
                            setHasOptionsMenu(true);
                    //        Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false);
                            Objects.requireNonNull( ((MainActivity) requireActivity())
                                    .getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
                    //        getSupportActionBar().setDisplayShowHomeEnabled(true);
                    
                            binding.progressBar.setVisibility(View.VISIBLE);
                    
                            binding.titleTextView.setText(title);
                            binding.blogContent.setMovementMethod(LinkMovementMethod.getInstance());
                    
                    
                            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                                binding.fab.bringToFront();
                            }
                    
                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                                binding.scrollView.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
                                    //   Log.d("ScrollView","scrollX_"+scrollX+"_scrollY_"+scrollY+"_oldScrollX_"+oldScrollX+"_oldScrollY_"+oldScrollY);
                                    if (scrollY > 0 && binding.fab.isShown()) {
                                        binding.fab.hide();
                                    } else if (scrollY < 22) {
                                        binding.fab.show();
                    
                                    }
                                });
                            } else {
                                binding.scrollView.getViewTreeObserver().addOnScrollChangedListener(() -> {
                                    int mScrollY = binding.scrollView.getScrollY();
                                    if (mScrollY > 0 && binding.fab.isShown()) {
                                        binding.fab.hide();
                                    } else if (mScrollY < 22) {
                                        binding.fab.show();
                                    }
                                });
                            }
                    
                    
                            binding.fab.setOnClickListener(view2 -> {
                                String shareContent = title + "\n" + url;
                                Intent shareIntent = new Intent(Intent.ACTION_SEND);
                                shareIntent.setType("text/plain");
                                shareIntent.putExtra(Intent.EXTRA_TEXT, shareContent);
                                shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    
                                try {
                                    startActivity(Intent.createChooser(shareIntent, title));
                                } catch (Exception exception) {
                                    Log.e(TAG, "onCreate: " + exception);
                                }
                            });
                    
                    
                            //       String imageSrc = getIntent().getStringExtra("blogImage");
                            //       Glide.with(getApplicationContext()).load(imageSrc).into(blogImage);
                    
                    
                            binding.youtubeThumbnailImage.setVisibility(youtubeThumbnailImageSetVisibility);
                            binding.youtubeThumbnailImage.setAdjustViewBounds(true);
                            Picasso.get().load(youtubeThumbnailImageSrc).into(binding.youtubeThumbnailImage);
                    
                            binding.youtubeThumbnailImage.setOnClickListener(view1 -> {
                                Intent youTube = new Intent
                                        (Intent.ACTION_VIEW, Uri.parse(youTubeLink));
                                startActivity(youTube);
                            });
                    
                    
                            PicassoImageGetter imageGetter = new PicassoImageGetter(binding.blogContent, requireContext());
                            Spannable html;
                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                                html = (Spannable) Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY, imageGetter, null);
                            } else {
                                html = (Spannable) Html.fromHtml(content, imageGetter, null);
                            }
                    
                            binding.blogContent.setText(html);
                    
                    
                            binding.visitSite.setOnClickListener(view3 -> openCustomTab(requireContext(), Uri.parse(url)));
                            binding.progressBar.setVisibility(View.GONE);
                        }
                    
                        private Item postItem;
                        private boolean postFavoritesSaved = false;
                        private int postFavoritesSavedId = 0;
                        private MenuItem menuItem;
                    
                        @Override
                        public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container,
                                                 Bundle savedInstanceState) {
                            // Inflate the layout for this fragment
                            binding =  FragmentDetailsBinding.inflate(inflater, container, false);
                            return binding.getRoot();
                        }
                    
                    
                        @Override
                        public void onCreateOptionsMenu(@NonNull Menu menu,
                                                        @NonNull MenuInflater inflater) {
                            super.onCreateOptionsMenu(menu, inflater);
                            inflater.inflate(R.menu.activity_details_menu, menu);
                            menuItem = menu.findItem(R.id.action_add_to_favorites);
                            checkSavedFavoritesItems(menuItem);
                        }
                    
                        @Override
                        public void onDestroyView() {
                            super.onDestroyView();
                            menuItem.setIcon(R.drawable.ic_favorite_border);
                        }
                    
                        private void checkSavedFavoritesItems(MenuItem menuItem) {
                            postViewModel.getAllFavorites().observe(this, favoritesEntity -> {
                                try {
                                    for (FavoritesEntity savedPost: favoritesEntity) {
                                        if (savedPost.getItem().getId().equals(postItem.getId())) {
                                            menuItem.setIcon(R.drawable.ic_favorite);
                                            postFavoritesSavedId = savedPost.getId();
                                            Log.d(TAG, "checkSavedFavoritesItems: " + postFavoritesSavedId);
                                            postFavoritesSaved = true;
                                        }
                                    }
                                } catch (Exception exception) {
                                    Log.e(TAG, "checkSavedFavoritesItems: " + exception.getMessage());
                                }
                            });
                        }
                    
                        @Override
                        public boolean onOptionsItemSelected(MenuItem menuItem) {
                    
                            if (menuItem.getItemId() == R.id.action_add_to_favorites && !postFavoritesSaved) {
                                saveTogFavorites(menuItem);
                            } else if (menuItem.getItemId() == R.id.action_add_to_favorites && postFavoritesSaved) {
                                removePostFromFavorites(menuItem);
                            } else if (menuItem.getItemId() == R.id.action_share) {
                                ShareActionProvider shareActionProvider =
                                        (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
                                shareActionProvider.setShareIntent(createShareIntent());
                                return true;
                            } else if (menuItem.getItemId() == R.id.copyTheLink) {
                                ClipboardManager clipboardManager = (ClipboardManager)
                                        requireActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                                ClipData clipData = ClipData.newPlainText("link", url);
                                assert clipboardManager != null;
                                clipboardManager.setPrimaryClip(clipData);
                                Toast.makeText(requireContext(), getString(R.string.linkCopied), Toast.LENGTH_LONG).show();
                                return true;
                            }
                    
                            return super.onOptionsItemSelected(menuItem);
                        }
                    
                        private void saveTogFavorites(MenuItem menuItem) {
                            FavoritesEntity favoritesEntity = new FavoritesEntity(0,
                                    postItem);
                    
                            postViewModel.insertFavorites(favoritesEntity);
                            menuItem.setIcon(R.drawable.ic_favorite);
                            Snackbar.make(binding.getRoot(), "Saved", Snackbar.LENGTH_LONG).show();
                            postFavoritesSaved = true;
                        }
                    
                    
                        private void removePostFromFavorites(MenuItem menuItem) {
                            FavoritesEntity favoritesEntity = new FavoritesEntity(postFavoritesSavedId,
                                    postItem);
                    
                            Log.d(TAG, "checkSavedFavoritesItems: " + postFavoritesSavedId);
                            postViewModel.deleteFavoritePost(favoritesEntity);
                            menuItem.setIcon(R.drawable.ic_favorite_border);
                            Snackbar.make(binding.getRoot(),
                                    "Post deleted from favorites", Snackbar.LENGTH_LONG).show();
                            postFavoritesSaved = false;
                        }
                    
                    <?xml version="1.0" encoding="utf-8"?>
                    <navigation 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:id="@+id/mobile_navigation"
                        app:startDestination="@id/nav_home">
                    
                        <fragment
                            android:id="@+id/nav_home"
                            android:name="com.blogspot.abtallaldigital.ui.home.HomeFragment"
                            android:label="@string/home"
                            tools:layout="@layout/fragment_home">
                            <action
                                android:id="@+id/action_nav_home_to_detailsFragment"
                                app:destination="@id/detailsFragment"
                                app:popUpTo="@id/nav_home" />
                        </fragment>
                    
                        <fragment
                            android:id="@+id/nav_Accessory"
                            android:name="com.blogspot.abtallaldigital.ui.accessory.AccessoryFragment"
                            android:label="@string/accessory"
                            tools:layout="@layout/fragment_accessory" >
                            <action
                                android:id="@+id/action_nav_Accessory_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                    
                        <fragment
                            android:id="@+id/nav_Arcade"
                            android:name="com.blogspot.abtallaldigital.ui.arcade.ArcadeFragment"
                            android:label="@string/arcade"
                            tools:layout="@layout/fragment_arcade" >
                            <action
                                android:id="@+id/action_nav_Arcade_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                    
                        <fragment
                            android:id="@+id/nav_Fashion"
                            android:name="com.blogspot.abtallaldigital.ui.fashion.FashionFragment"
                            android:label="@string/fashion"
                            tools:layout="@layout/fashion_fragment" >
                            <action
                                android:id="@+id/action_nav_Fashion_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Food"
                            android:name="com.blogspot.abtallaldigital.ui.food.FoodFragment"
                            android:label="@string/food"
                            tools:layout="@layout/food_fragment" >
                            <action
                                android:id="@+id/action_nav_Food_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Heath"
                            android:name="com.blogspot.abtallaldigital.ui.heath.HeathFragment"
                            android:label="@string/heath"
                            tools:layout="@layout/heath_fragment" >
                            <action
                                android:id="@+id/action_nav_Heath_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Lifestyle"
                            android:name="com.blogspot.abtallaldigital.ui.lifestyle.LifestyleFragment"
                            android:label="@string/lifestyle"
                            tools:layout="@layout/lifestyle_fragment" >
                            <action
                                android:id="@+id/action_nav_Lifestyle_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Sports"
                            android:name="com.blogspot.abtallaldigital.ui.sports.SportsFragment"
                            android:label="@string/sports"
                            tools:layout="@layout/sports_fragment" >
                            <action
                                android:id="@+id/action_nav_Sports_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <dialog
                            android:id="@+id/about"
                            android:name="com.blogspot.abtallaldigital.ui.about.AboutFragment"
                            android:label="about"
                            tools:layout="@layout/about" />
                        <fragment
                            android:id="@+id/detailsFragment"
                            android:name="com.blogspot.abtallaldigital.ui.DetailsFragment"
                            android:label="Post details"
                            tools:layout="@layout/fragment_details" >
                            <argument
                                android:name="postItem"
                                app:argType="com.blogspot.abtallaldigital.pojo.Item" />
                        </fragment>
                    </navigation>
                    
                    @Override
                        public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
                            super.onViewCreated(view, savedInstanceState);
                    
                            navController = Navigation.findNavController(requireView());
                    
                            binding.homeRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(requireContext(),
                                    binding.homeRecyclerView, new RecyclerItemClickListener.OnItemClickListener() {
                                @Override
                                public void onItemClick(View view, int position) {
                    
                                    Item item = itemArrayList.get(position);
                    
                                    if (Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.nav_home) {
                                        Navigation.findNavController(requireView())
                                                .navigate(HomeFragmentDirections.actionNavHomeToDetailsFragment(item));
                                    }
                    
                                }
                    
                                @Override
                                public void onLongItemClick(View view, int position) {
                    
                                }
                            }
                            ));
                        }
                    
                    public class DetailsFragment extends Fragment {
                    
                        private static final String TAG = "DetailsFragment";
                    
                        private FragmentDetailsBinding binding;
                    
                        String url, title, content, youtubeThumbnailImageSrc, youTubeLink;
                        int youtubeThumbnailImageSetVisibility;
                        private PostViewModel postViewModel;
                    
                        @Override
                        public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
                            super.onViewCreated(view, savedInstanceState);
                    
                            postViewModel = new ViewModelProvider(this).get(PostViewModel.class);
                            Log.d(TAG, "onCreate checkSavedFavoritesItems: " + postFavoritesSavedId);
                    
                    
                            postItem = DetailsFragmentArgs.fromBundle(getArguments()).getPostItem();
                    
                    
                            final Document document = Jsoup.parse(postItem.getContent());
                    //                    final Elements elements = document.select("img");
                    
                            Element element = document.body();
                    
                            for (Element e : element.getElementsByClass
                                    ("YOUTUBE-iframe-video")) {
                                youtubeThumbnailImageSrc = e.attr("data-thumbnail-src");
                                youTubeLink = e.attr("src");
                                Log.e("YouTube thumbnail", youtubeThumbnailImageSrc);
                                Log.e("Youtube link", youTubeLink);
                            }
                    
                            if (youtubeThumbnailImageSrc == null) {
                                youtubeThumbnailImageSetVisibility = 8;
                            }
                    
                            url = postItem.getUrl();
                            title = postItem.getTitle();
                            content = postItem.getContent();
                    
                    
                            //        blogImage = (ImageView) findViewById(R.id.blogImage);
                    
                            setHasOptionsMenu(true);
                    //        Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false);
                            Objects.requireNonNull( ((MainActivity) requireActivity())
                                    .getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
                    //        getSupportActionBar().setDisplayShowHomeEnabled(true);
                    
                            binding.progressBar.setVisibility(View.VISIBLE);
                    
                            binding.titleTextView.setText(title);
                            binding.blogContent.setMovementMethod(LinkMovementMethod.getInstance());
                    
                    
                            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                                binding.fab.bringToFront();
                            }
                    
                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                                binding.scrollView.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
                                    //   Log.d("ScrollView","scrollX_"+scrollX+"_scrollY_"+scrollY+"_oldScrollX_"+oldScrollX+"_oldScrollY_"+oldScrollY);
                                    if (scrollY > 0 && binding.fab.isShown()) {
                                        binding.fab.hide();
                                    } else if (scrollY < 22) {
                                        binding.fab.show();
                    
                                    }
                                });
                            } else {
                                binding.scrollView.getViewTreeObserver().addOnScrollChangedListener(() -> {
                                    int mScrollY = binding.scrollView.getScrollY();
                                    if (mScrollY > 0 && binding.fab.isShown()) {
                                        binding.fab.hide();
                                    } else if (mScrollY < 22) {
                                        binding.fab.show();
                                    }
                                });
                            }
                    
                    
                            binding.fab.setOnClickListener(view2 -> {
                                String shareContent = title + "\n" + url;
                                Intent shareIntent = new Intent(Intent.ACTION_SEND);
                                shareIntent.setType("text/plain");
                                shareIntent.putExtra(Intent.EXTRA_TEXT, shareContent);
                                shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    
                                try {
                                    startActivity(Intent.createChooser(shareIntent, title));
                                } catch (Exception exception) {
                                    Log.e(TAG, "onCreate: " + exception);
                                }
                            });
                    
                    
                            //       String imageSrc = getIntent().getStringExtra("blogImage");
                            //       Glide.with(getApplicationContext()).load(imageSrc).into(blogImage);
                    
                    
                            binding.youtubeThumbnailImage.setVisibility(youtubeThumbnailImageSetVisibility);
                            binding.youtubeThumbnailImage.setAdjustViewBounds(true);
                            Picasso.get().load(youtubeThumbnailImageSrc).into(binding.youtubeThumbnailImage);
                    
                            binding.youtubeThumbnailImage.setOnClickListener(view1 -> {
                                Intent youTube = new Intent
                                        (Intent.ACTION_VIEW, Uri.parse(youTubeLink));
                                startActivity(youTube);
                            });
                    
                    
                            PicassoImageGetter imageGetter = new PicassoImageGetter(binding.blogContent, requireContext());
                            Spannable html;
                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                                html = (Spannable) Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY, imageGetter, null);
                            } else {
                                html = (Spannable) Html.fromHtml(content, imageGetter, null);
                            }
                    
                            binding.blogContent.setText(html);
                    
                    
                            binding.visitSite.setOnClickListener(view3 -> openCustomTab(requireContext(), Uri.parse(url)));
                            binding.progressBar.setVisibility(View.GONE);
                        }
                    
                        private Item postItem;
                        private boolean postFavoritesSaved = false;
                        private int postFavoritesSavedId = 0;
                        private MenuItem menuItem;
                    
                        @Override
                        public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container,
                                                 Bundle savedInstanceState) {
                            // Inflate the layout for this fragment
                            binding =  FragmentDetailsBinding.inflate(inflater, container, false);
                            return binding.getRoot();
                        }
                    
                    
                        @Override
                        public void onCreateOptionsMenu(@NonNull Menu menu,
                                                        @NonNull MenuInflater inflater) {
                            super.onCreateOptionsMenu(menu, inflater);
                            inflater.inflate(R.menu.activity_details_menu, menu);
                            menuItem = menu.findItem(R.id.action_add_to_favorites);
                            checkSavedFavoritesItems(menuItem);
                        }
                    
                        @Override
                        public void onDestroyView() {
                            super.onDestroyView();
                            menuItem.setIcon(R.drawable.ic_favorite_border);
                        }
                    
                        private void checkSavedFavoritesItems(MenuItem menuItem) {
                            postViewModel.getAllFavorites().observe(this, favoritesEntity -> {
                                try {
                                    for (FavoritesEntity savedPost: favoritesEntity) {
                                        if (savedPost.getItem().getId().equals(postItem.getId())) {
                                            menuItem.setIcon(R.drawable.ic_favorite);
                                            postFavoritesSavedId = savedPost.getId();
                                            Log.d(TAG, "checkSavedFavoritesItems: " + postFavoritesSavedId);
                                            postFavoritesSaved = true;
                                        }
                                    }
                                } catch (Exception exception) {
                                    Log.e(TAG, "checkSavedFavoritesItems: " + exception.getMessage());
                                }
                            });
                        }
                    
                        @Override
                        public boolean onOptionsItemSelected(MenuItem menuItem) {
                    
                            if (menuItem.getItemId() == R.id.action_add_to_favorites && !postFavoritesSaved) {
                                saveTogFavorites(menuItem);
                            } else if (menuItem.getItemId() == R.id.action_add_to_favorites && postFavoritesSaved) {
                                removePostFromFavorites(menuItem);
                            } else if (menuItem.getItemId() == R.id.action_share) {
                                ShareActionProvider shareActionProvider =
                                        (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
                                shareActionProvider.setShareIntent(createShareIntent());
                                return true;
                            } else if (menuItem.getItemId() == R.id.copyTheLink) {
                                ClipboardManager clipboardManager = (ClipboardManager)
                                        requireActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                                ClipData clipData = ClipData.newPlainText("link", url);
                                assert clipboardManager != null;
                                clipboardManager.setPrimaryClip(clipData);
                                Toast.makeText(requireContext(), getString(R.string.linkCopied), Toast.LENGTH_LONG).show();
                                return true;
                            }
                    
                            return super.onOptionsItemSelected(menuItem);
                        }
                    
                        private void saveTogFavorites(MenuItem menuItem) {
                            FavoritesEntity favoritesEntity = new FavoritesEntity(0,
                                    postItem);
                    
                            postViewModel.insertFavorites(favoritesEntity);
                            menuItem.setIcon(R.drawable.ic_favorite);
                            Snackbar.make(binding.getRoot(), "Saved", Snackbar.LENGTH_LONG).show();
                            postFavoritesSaved = true;
                        }
                    
                    
                        private void removePostFromFavorites(MenuItem menuItem) {
                            FavoritesEntity favoritesEntity = new FavoritesEntity(postFavoritesSavedId,
                                    postItem);
                    
                            Log.d(TAG, "checkSavedFavoritesItems: " + postFavoritesSavedId);
                            postViewModel.deleteFavoritePost(favoritesEntity);
                            menuItem.setIcon(R.drawable.ic_favorite_border);
                            Snackbar.make(binding.getRoot(),
                                    "Post deleted from favorites", Snackbar.LENGTH_LONG).show();
                            postFavoritesSaved = false;
                        }
                    
                    <?xml version="1.0" encoding="utf-8"?>
                    <navigation 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:id="@+id/mobile_navigation"
                        app:startDestination="@id/nav_home">
                    
                        <fragment
                            android:id="@+id/nav_home"
                            android:name="com.blogspot.abtallaldigital.ui.home.HomeFragment"
                            android:label="@string/home"
                            tools:layout="@layout/fragment_home">
                            <action
                                android:id="@+id/action_nav_home_to_detailsFragment"
                                app:destination="@id/detailsFragment"
                                app:popUpTo="@id/nav_home" />
                        </fragment>
                    
                        <fragment
                            android:id="@+id/nav_Accessory"
                            android:name="com.blogspot.abtallaldigital.ui.accessory.AccessoryFragment"
                            android:label="@string/accessory"
                            tools:layout="@layout/fragment_accessory" >
                            <action
                                android:id="@+id/action_nav_Accessory_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                    
                        <fragment
                            android:id="@+id/nav_Arcade"
                            android:name="com.blogspot.abtallaldigital.ui.arcade.ArcadeFragment"
                            android:label="@string/arcade"
                            tools:layout="@layout/fragment_arcade" >
                            <action
                                android:id="@+id/action_nav_Arcade_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                    
                        <fragment
                            android:id="@+id/nav_Fashion"
                            android:name="com.blogspot.abtallaldigital.ui.fashion.FashionFragment"
                            android:label="@string/fashion"
                            tools:layout="@layout/fashion_fragment" >
                            <action
                                android:id="@+id/action_nav_Fashion_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Food"
                            android:name="com.blogspot.abtallaldigital.ui.food.FoodFragment"
                            android:label="@string/food"
                            tools:layout="@layout/food_fragment" >
                            <action
                                android:id="@+id/action_nav_Food_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Heath"
                            android:name="com.blogspot.abtallaldigital.ui.heath.HeathFragment"
                            android:label="@string/heath"
                            tools:layout="@layout/heath_fragment" >
                            <action
                                android:id="@+id/action_nav_Heath_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Lifestyle"
                            android:name="com.blogspot.abtallaldigital.ui.lifestyle.LifestyleFragment"
                            android:label="@string/lifestyle"
                            tools:layout="@layout/lifestyle_fragment" >
                            <action
                                android:id="@+id/action_nav_Lifestyle_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <fragment
                            android:id="@+id/nav_Sports"
                            android:name="com.blogspot.abtallaldigital.ui.sports.SportsFragment"
                            android:label="@string/sports"
                            tools:layout="@layout/sports_fragment" >
                            <action
                                android:id="@+id/action_nav_Sports_to_detailsFragment"
                                app:destination="@id/detailsFragment" />
                        </fragment>
                        <dialog
                            android:id="@+id/about"
                            android:name="com.blogspot.abtallaldigital.ui.about.AboutFragment"
                            android:label="about"
                            tools:layout="@layout/about" />
                        <fragment
                            android:id="@+id/detailsFragment"
                            android:name="com.blogspot.abtallaldigital.ui.DetailsFragment"
                            android:label="Post details"
                            tools:layout="@layout/fragment_details" >
                            <argument
                                android:name="postItem"
                                app:argType="com.blogspot.abtallaldigital.pojo.Item" />
                        </fragment>
                    </navigation>
                    
                    @Override
                        public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
                            super.onViewCreated(view, savedInstanceState);
                    
                            navController = Navigation.findNavController(requireView());
                    
                            binding.homeRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(requireContext(),
                                    binding.homeRecyclerView, new RecyclerItemClickListener.OnItemClickListener() {
                                @Override
                                public void onItemClick(View view, int position) {
                    
                                    Item item = itemArrayList.get(position);
                    
                                    if (Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.nav_home) {
                                        Navigation.findNavController(requireView())
                                                .navigate(HomeFragmentDirections.actionNavHomeToDetailsFragment(item));
                                    }
                    
                                }
                    
                                @Override
                                public void onLongItemClick(View view, int position) {
                    
                                }
                            }
                            ));
                        }
                    

                    Community Discussions

                    Trending Discussions on Spannable
                    • how to make ellipsized text with rules character more than 65 in android?
                    • Auto Scrollable Text View in Kotlin
                    • SpannableStringBuilder , ClickSpan not working , clickspan to multiple strings android
                    • How to bold title in notification?
                    • Android get ArrayList from Room Database in adapter class
                    • how to insert Image from gallery to a EditTex View?
                    • Keeping 2D interpolation within shape
                    • onCreateOptionsMenu showing alwasy as action with a menu that i have created programatically
                    • How to search a SpannableString without knowing the exact substring
                    • How to find index of a substring in a SpannableString
                    Trending Discussions on Spannable

                    QUESTION

                    how to make ellipsized text with rules character more than 65 in android?

                    Asked 2022-Apr-02 at 15:59
                        class EllipsizedTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0): AppCompatTextView(context, attrs, defStyleAttr) {
                        
                            private var ellipsis = getDefaultEllipsis().toString()
                            private var ellipsisColor = getDefaultEllipsisColor()
                            private var isEllipsis = false
                        
                            private var ellipsizedText: CharSequence? = null
                            private var callbackEllipsized: MoreClickableSpan? = null
                        
                            init {
                                attrs?.let { attributeSet ->
                                    context.theme.obtainStyledAttributes(attributeSet, R.styleable.EllipsizedTextView, 0, 0).apply {
                                        ellipsis = getString(R.styleable.EllipsizedTextView_ellipsis) ?: getDefaultEllipsis().toString()
                                        ellipsisColor = getColor(R.styleable.EllipsizedTextView_ellipsisColor, getDefaultEllipsisColor())
                        
                                        recycle()
                                    }
                                }
                            }
                        
                            override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
                                super.onMeasure(widthMeasureSpec, heightMeasureSpec)
                        
                                /*
                                    Prepare to set custom ellipsize text
                                 */
                        
                                val availableScreenWidth = measuredWidth - compoundPaddingLeft.toFloat() - compoundPaddingRight.toFloat()
                                var availableTextWidth = availableScreenWidth * maxLines
                        
                                ellipsizedText = TextUtils.ellipsize(text, paint, availableTextWidth, ellipsize, false) { start, end ->
                                    isEllipsis = start != 0 && end >= 65
                                }
                        
                                if (isEllipsis) { // check if current text is ellipsized or not
                                    printLog("isEllipsis: $ellipsizedText ellipsis: $ellipsis, text : $text")
                                    // If the ellipsizedText is different than the original text, this means that it didn't fit and got indeed ellipsized.
                                    // Calculate the new availableTextWidth by taking into consideration the size of the custom ellipsis, too.
                                    availableTextWidth = (availableScreenWidth - paint.measureText(ellipsis)) * maxLines
                                    ellipsizedText = TextUtils.ellipsize(text, paint, availableTextWidth, ellipsize, false){ start, end ->
                                        isEllipsis = start != 0 && end >= 65
                                    }
                                }
                        
                                setEllipsizedText(ellipsizedText, isEllipsis)
                            }
                            
                            private fun setEllipsizedText(value: CharSequence?, isEllipsized: Boolean){
                                printLog("setEllipsizedText > $isEllipsized")
                                if(isEllipsized){
                                    val resultText = "$value$ellipsis"
                                    val startPoint = resultText.indexOf(ellipsis)
                                    val endPoint = startPoint + ellipsis.length
                        
                                    val spannable = SpannableString(resultText).apply {
                                        callbackEllipsized?.let { callback ->
                                            printLog("setEllipsizedText > implement callbackEllipsized")
                        
                                            // set event click on spannable
                                            setSpan(callback, startPoint, endPoint, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
                        
                                            // set color on target text while enable to click
                                            setSpan(ForegroundColorSpan(ellipsisColor), startPoint, endPoint, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
                                        }
                                    }
                        
                                    //val defaultEllipsisStart = value.indexOf(getDefaultEllipsis())
                                    //val defaultEllipsisEnd = defaultEllipsisStart + 1
                                    //text = spannableStringBuilder.append(ellipsizedText).replace(defaultEllipsisStart, defaultEllipsisEnd, ellipsisSpannable)
                                    text = spannable
                                    movementMethod = LinkMovementMethod.getInstance()
                        
                                    printLog("setEllipsizedText > text : $text")
                                }
                            }
                        
                            private fun getDefaultEllipsis(): Char {
                                return Typography.ellipsis
                            }
                        
                            private fun getDefaultEllipsisColor(): Int {
                                return textColors.defaultColor
                            }
                        
                            fun setActionClickEllipse(callback: MoreClickableSpan){
                                this.callbackEllipsized = callback
                            }
                        
                            fun isReadMore(): Boolean = isEllipsis
                        
                            @Suppress("unused_parameter")
                            fun printLog(msg: String) { }
                        
                            open class MoreClickableSpan : ClickableSpan() {
                        
                                override fun onClick(widget: View) {}
                        
                                override fun updateDrawState(ds: TextPaint) {}
                            }
                        }
                    

                    How to implement ellipsized text with rules if more than 65 character? my existing code below like this

                    ANSWER

                    Answered 2022-Jan-28 at 05:25

                    Why don't you add this to your TextView in the xml file?It will limit it to 65 chars and it will show ellipse after that

                    android:maxLength="65" 
                    android:ellipsize="end"
                    android:maxLines="1"
                    

                    Source https://stackoverflow.com/questions/70888730

                    Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                    Vulnerabilities

                    No vulnerabilities reported

                    Install Spannable

                    You can download it from GitHub.
                    You can use Spannable like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the Spannable component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

                    Support

                    For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

                    DOWNLOAD this Library from

                    Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                    over 430 million Knowledge Items
                    Find more libraries
                    Reuse Solution Kits and Libraries Curated by Popular Use Cases
                    Explore Kits

                    Save this library and start creating your kit

                    Share this Page

                    share link
                    Consider Popular Java Libraries
                    Try Top Libraries by krishnalalstha
                    Compare Java Libraries with Highest Support
                    Compare Java Libraries with Highest Quality
                    Compare Java Libraries with Highest Security
                    Compare Java Libraries with Permissive License
                    Compare Java Libraries with Highest Reuse
                    Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                    over 430 million Knowledge Items
                    Find more libraries
                    Reuse Solution Kits and Libraries Curated by Popular Use Cases
                    Explore Kits

                    Save this library and start creating your kit

                    • © 2022 Open Weaver Inc.