Listactivity error with jelly bean running device ( SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length)

前端 未结 3 850
无人共我
无人共我 2021-02-20 10:24

I have app start with Splash screen then open listactivity rows, clicking on any row will opens an activity containing a textview, two buttons (one of which opens an infinite ga

3条回答
  •  滥情空心
    2021-02-20 11:14

    The compiler may not be able to parse/use the Arabic (correct me if I'm wrong) text.

    You can try by explicitly setting each String under UTF-8:

    String[] classes = 
        {
            new String("example1".getBytes(), "UTF-8"),
            new String("example2".getBytes(), "UTF-8")
        };
    

    Do the same for the calls to equals in the onListItemClick

    String cheese = new String(classes[position].getBytes(), "UTF-8");
    
        if(cheese.equals(new String("المقدمة".getBytes(), "UTF-8")))
        {
            cheese = new String("Introduction".getBytes(), "UTF-8");
        }
    

    Better yet, just make a method.

    private Object stringUTF8(final Object string)
    {
        try
        {
            return new String(((String) string).getBytes(), "UTF-8");
        }
        catch(UnsupportedEncodingException e)
        {
            e.printStackTrace();
    
            return "error";
        }
    }
    

提交回复
热议问题