Make title text bold when sharing

独自空忆成欢 提交于 2020-01-05 00:44:27

问题


Here, the code below will share the content onclick. While sharing the content through other app there are two contents: one is ti - title, another is de - description. I want to make the title bold while sharing. Is that possible?

expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

    @Override
    public boolean onChildClick(ExpandableListView parent, View v,
                                int groupPosition, int childPosition, long id) {
        // TODO Auto-generated method stub

        TextView de = (TextView) v.findViewById(R.id.lblListItem);
        TextView ti = (TextView) v.findViewById(R.id.lblListHeader);


        String selected = ti.getText().toString() + de.getText().toString();
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, selected);
        startActivity(Intent.createChooser(intent, "Share via"));

        return false;
    }
});

回答1:


Assuming your question is how to make the title(ti) bold right before sharing, you can try:

ti.setTypeface(null, Typeface.BOLD);



回答2:


It's almost impossible. Once you share text for other apps, this text is displayed control by these apps. You can't do anything in there. Unless they provide options for you to format text for display.




回答3:


Considering your problem of Setting the content to bold you could do it via XML using the following code: android:textStyle="bold"

and via Java class i.e Programmatically using: textView.setTypeface(null, Typeface.BOLD);




回答4:


If you want to share any thing on Whatsapp then there is small trick just use "*" in starting of any text and ending of the text then your text on Whatsapp will show bold.

final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
                    String shareMessage =  "*"+"Download theguruji app for more news\n\n"+"*";
                    intent.putExtra(Intent.EXTRA_TEXT, shareMessage);
                    intent.setType("text/plain");
                    startActivity(Intent.createChooser(intent, "Share  via"));


来源:https://stackoverflow.com/questions/52042434/make-title-text-bold-when-sharing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!