从画廊中选择字体并在下一页显示

发布于 2025-02-10 00:06:11 字数 3355 浏览 0 评论 0原文

我想根据是否从水平gridview中选择的类型face的字体来设置字体的字体,该字体是否具有常规字体类型等字体类型等,另一个水平gridview具有霓虹灯字体字体。字形没问题,但是当我按下后退按钮并选择了普通的fonttype时,所选字体不会按需要显示。

font_style_ga =(画廊)findviewbyid(r.id.font_style_ga);

    font_style_ga.setAdapter(new FontStyle(this));

font_style_ga.setOnitemClickListener(新的OnItemClickListener(){

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1,
                                int position, long arg3) {

            if (IsNativeAdVisible) {
                return;
            }
            if (position == 0) {
                externalFont = Typeface.createFromAsset(getAssets(),
                        "Creator_Campotype_smcp.otf");
            } else if (position == 1) {
                externalFont = Typeface.createFromAsset(getAssets(),
                        "Gangnam.ttf");
            } 

similarty for Neontypeface as as neon_font_ga.setOnitemClickListener(新的OnItemClickListener(){ @Override &lt;?

            if (IsNativeAdVisible) {
                return;
            }
            if(position==0){
                neonFonts=Typeface.createFromAsset(getAssets(),
                        "Neony_font.ttf");
            }


                NeontypeFaceName= neonTypeList[position];
                text_edt.setTextSize(textsize);
                text_edt.setTypeface(neonFonts);



        }
    });


Intent intent = new Intent(TextActivity.this,
                            FirstActivity.class);
                    intent.putExtra("text", edit_text_str);
                    intent.putExtra("textcolor", textcolor);
                    intent.putExtra("textsize", textsize);
                    intent.putExtra("typeface", typeFaceName);
                    intent.putExtra("neonTypeface",NeontypeFaceName);
                    startActivity(intent);

public void onItemClick( adapterView /code>或neontypefacename是使用否则条件设置的,

if (bundleIntent != null) {


        adText.setText(bundleIntent.getExtras().getString("text"));


        if (bundleIntent.getExtras().getString("typeface") == null ) {

            adText.setTypeface(Typeface.DEFAULT);

        } else {

            Typeface typeFace = Typeface.createFromAsset(getAssets(),
                    bundleIntent.getExtras().getString("typeface"));

            adText.setTypeface(typeFace);

        }

        adText.setTextSize(bundleIntent.getExtras().getFloat("textsize"));

        int color = bundleIntent.getExtras().getInt("textcolor");

        if (color == 0) {

            color = Color.BLACK;
        }
        adText.setTextColor(color);


        if(bundleIntent.getExtras().getString("neonTypeface")!=null  ){
            Typeface typeFace = Typeface.createFromAsset(getAssets(),
                    bundleIntent.getExtras().getString("neonTypeface"));

            adText.setTypeface(typeFace);
            adText.setShadowLayer(11,2,-2,color);


        }else if(bundleIntent.getExtras().getString("typeface")!=null){
            Typeface typeFace = Typeface.createFromAsset(getAssets(),
                    bundleIntent.getExtras().getString("typeface"));

            adText.setTypeface(typeFace);
        }

但是在向后下方和更改字体后将无法选择字体。请帮忙

I want to set typeface of fonts of two different types according to whether type face selected from horizontal gridview which has font types like regular etc another horizontal gridview has neon typeface font.problem is that when i select from neontype face from grid row it displays neon typeface no problem ,but when i pressed back button and selected normal fonttype but the selected font would not display as desired .Here is code

font_style_ga = (Gallery) findViewById(R.id.font_style_ga);

    font_style_ga.setAdapter(new FontStyle(this));

font_style_ga.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1,
                                int position, long arg3) {

            if (IsNativeAdVisible) {
                return;
            }
            if (position == 0) {
                externalFont = Typeface.createFromAsset(getAssets(),
                        "Creator_Campotype_smcp.otf");
            } else if (position == 1) {
                externalFont = Typeface.createFromAsset(getAssets(),
                        "Gangnam.ttf");
            } 

Similarty for neontypeface as
neon_font_ga.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            if (IsNativeAdVisible) {
                return;
            }
            if(position==0){
                neonFonts=Typeface.createFromAsset(getAssets(),
                        "Neony_font.ttf");
            }


                NeontypeFaceName= neonTypeList[position];
                text_edt.setTextSize(textsize);
                text_edt.setTypeface(neonFonts);



        }
    });


Intent intent = new Intent(TextActivity.this,
                            FirstActivity.class);
                    intent.putExtra("text", edit_text_str);
                    intent.putExtra("textcolor", textcolor);
                    intent.putExtra("textsize", textsize);
                    intent.putExtra("typeface", typeFaceName);
                    intent.putExtra("neonTypeface",NeontypeFaceName);
                    startActivity(intent);

In firstactivity.java I am using getextra function whether typeface or NeontypeFaceName is set using if else condition as

if (bundleIntent != null) {


        adText.setText(bundleIntent.getExtras().getString("text"));


        if (bundleIntent.getExtras().getString("typeface") == null ) {

            adText.setTypeface(Typeface.DEFAULT);

        } else {

            Typeface typeFace = Typeface.createFromAsset(getAssets(),
                    bundleIntent.getExtras().getString("typeface"));

            adText.setTypeface(typeFace);

        }

        adText.setTextSize(bundleIntent.getExtras().getFloat("textsize"));

        int color = bundleIntent.getExtras().getInt("textcolor");

        if (color == 0) {

            color = Color.BLACK;
        }
        adText.setTextColor(color);


        if(bundleIntent.getExtras().getString("neonTypeface")!=null  ){
            Typeface typeFace = Typeface.createFromAsset(getAssets(),
                    bundleIntent.getExtras().getString("neonTypeface"));

            adText.setTypeface(typeFace);
            adText.setShadowLayer(11,2,-2,color);


        }else if(bundleIntent.getExtras().getString("typeface")!=null){
            Typeface typeFace = Typeface.createFromAsset(getAssets(),
                    bundleIntent.getExtras().getString("typeface"));

            adText.setTypeface(typeFace);
        }

But after pressing back and changing typeface will not get selected typeface. Please help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文