当前位置: 首页>>代码示例>>Java>>正文


Java Html类代码示例

本文整理汇总了Java中android.text.Html的典型用法代码示例。如果您正苦于以下问题:Java Html类的具体用法?Java Html怎么用?Java Html使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Html类属于android.text包,在下文中一共展示了Html类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showCountryDetail

import android.text.Html; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void showCountryDetail(@NonNull Country country) {
    CollapsingToolbarLayout toolbarLayout =
            (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    toolbarLayout.setTitle(country.getCountryName());
    toolbarLayout.setExpandedTitleColor(ContextCompat.getColor(this, android.R.color.white));
    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle(country.getCountryName());
    }
    if (imageView != null ) {
         String flagUri = BuildConfig.GEONAME_ICON_URL +"x/" +
                 country.getCountryCode().toLowerCase() + ".gif";
        imageView.setImageURI(Uri.parse(flagUri));
    }
    tvCapital.setText(getString(R.string.format_country_capital,country.getCapital()));
    tvContinent.setText(getString(R.string.format_country_continent,country.getContinentName()));
    tvCode.setText(getString(R.string.format_country_code,country.getCountryCode()));
    tvArea.setText(Html.fromHtml(getString(R.string.format_country_area,country.getAreaInSqKm())));
    tvPopulation.setText(getString(R.string.format_country_population,country.getPopulation()));
    tvSouth.setText(getString(R.string.format_country_south,country.getSouth()));
    tvEast.setText(getString(R.string.format_country_east,country.getEast()));
    tvNorth.setText(getString(R.string.format_country_north,country.getNorth()));
    tvWest.setText(getString(R.string.format_country_west,country.getWest()));
}
 
开发者ID:graviton57,项目名称:NewAndroidArchitecture,代码行数:25,代码来源:DetailActivity.java

示例2: setUpAskHnStoryText

import android.text.Html; //导入依赖的package包/类
private void setUpAskHnStoryText(final Item item) {
    if (item.getText() != null) {
        TextView storyText = (TextView) findViewById(R.id.story_text);
        storyText.setText(Html.fromHtml(item.getText()));
        storyText.setOnClickListener(new View.OnClickListener() {
            private boolean minimized;

            @Override
            public void onClick(View v) {
                if (!minimized) {
                    storyText.setText("<<Click to expand>>");
                    minimized = true;
                } else {
                    storyText.setText(Html.fromHtml(item.getText()));
                    minimized = false;
                }
            }
        });
    }
}
 
开发者ID:dandanes7,项目名称:lurkerhn,代码行数:21,代码来源:StoryContentActivity.java

示例3: getKakaoData

import android.text.Html; //导入依赖的package包/类
private KakaoData getKakaoData(String room, Object text) {
    KakaoData result = new KakaoData();

    result.room = room;

    if(text instanceof String) {
        result.sender = room;
        result.message = text.toString();
    } else {
        String html = Html.toHtml((SpannableString) text);
        result.sender = Html.fromHtml(html.split("<b>")[1].split("</b>")[0]).toString();
        result.message = Html.fromHtml(html.split("</b>")[1].split("</p>")[0].substring(1)).toString();
    }

    return result;
}
 
开发者ID:Su-Yong,项目名称:NewKakaoBot,代码行数:17,代码来源:KakaoTalkListener.java

示例4: showSupportersDialog

import android.text.Html; //导入依赖的package包/类
private void showSupportersDialog() {
    final Dialog fullscreenDialog = new Dialog(this, R.style.DialogFullscreen);
    fullscreenDialog.setContentView(R.layout.dialog_supporters);
    Button logoutB = fullscreenDialog.findViewById(R.id.logout_b);
    ImageView img_dialog_fullscreen_close = fullscreenDialog.findViewById(R.id.close_iv);
    TextView collaborationTV = fullscreenDialog.findViewById(R.id.info_collaboration_tv);
    collaborationTV.setText(Html.fromHtml(getString(R.string.collaboration)));
    img_dialog_fullscreen_close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fullscreenDialog.dismiss();
        }
    });
    logoutB.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            saveToken(context, "HOME", null);
            Intent intent = new Intent(context, ActivitySplash.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK |
                    Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            finish();
        }
    });

    fullscreenDialog.show();
}
 
开发者ID:faviotorres,项目名称:AcopioMX,代码行数:28,代码来源:ActivityHome.java

示例5: startActivity

import android.text.Html; //导入依赖的package包/类
private void startActivity(String action, Uri uri, String type, Map<String, String> extras, boolean bExpectResult, int requestCode, CallbackContext callbackContext) {
    //  Credit: https://github.com/chrisekelley/cordova-webintent
    Intent i = (uri != null ? new Intent(action, uri) : new Intent(action));

    if (type != null && uri != null) {
        i.setDataAndType(uri, type); //Fix the crash problem with android 2.3.6
    } else {
        if (type != null) {
            i.setType(type);
        }
        if (uri != null)
        {
            i.setData(uri);
        }
    }

    for (String key : extras.keySet()) {
        String value = extras.get(key);
        // If type is text html, the extra text must sent as HTML
        if (key.equals(Intent.EXTRA_TEXT) && type.equals("text/html")) {
            i.putExtra(key, Html.fromHtml(value));
        } else if (key.equals(Intent.EXTRA_STREAM)) {
            // allowes sharing of images as attachments.
            // value in this case should be a URI of a file
            final CordovaResourceApi resourceApi = webView.getResourceApi();
            i.putExtra(key, resourceApi.remapUri(Uri.parse(value)));
        } else if (key.equals(Intent.EXTRA_EMAIL)) {
            // allows to add the email address of the receiver
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { value });
        } else {
            i.putExtra(key, value);
        }
    }

    i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    if (i.resolveActivityInfo(this.cordova.getActivity().getPackageManager(), 0) != null)
    {
    if (bExpectResult)
    {
        cordova.setActivityResultCallback(this);
        ((CordovaActivity) this.cordova.getActivity()).startActivityForResult(i, requestCode);
    }
    else
        {
        ((CordovaActivity)this.cordova.getActivity()).startActivity(i);
            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
        }
    }
    else
    {
        //  Return an error as there is no app to handle this intent
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
    }
}
 
开发者ID:darryncampbell,项目名称:darryncampbell-cordova-plugin-intent,代码行数:56,代码来源:IntentShim.java

示例6: onCreate

import android.text.Html; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (PushServiceAccessibility.isInDozeWhiteList(this)) {
        nextPage();
        finish();
        return;
    }
    SetupWizardLayout layout = new SetupWizardLayout(this);
    layout.getNavigationBar()
            .setNavigationBarListener(this);
    TextView textView = new TextView(this);
    textView.setText(Html.fromHtml(getString(R.string.wizard_descr_doze_whitelist)));
    int padding = (int) getResources().getDimension(R.dimen.suw_glif_margin_sides);
    textView.setPadding(padding, padding, padding, padding);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    layout.addView(textView);
    layout.setHeaderText(R.string.wizard_title_doze_whitelist);
    setContentView(layout);
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:21,代码来源:CheckDozeActivity.java

示例7: onBindViewHolder

import android.text.Html; //导入依赖的package包/类
@Override
public void onBindViewHolder(NewsAdapter.NewsViewHolder holder, int position) {
    News news = mNews.get(position);
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
    SimpleDateFormat dateFormatDeux = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    Date createdDate = null;
    try {
        createdDate = dateFormat.parse(news.createdAt);
    } catch (Throwable e) {
        e.printStackTrace();
    }

    holder.title.setText(news.title);
    if (news.content != null)
        holder.description.setText(Html.fromHtml(news.content));
    if (news.createdAt != null)
        holder.date.setText(dateFormatDeux.format(createdDate));
    holder.cardView.setOnClickListener(v -> mNewsPresenter.showNewsDetail(news._id));

    int pos = holder.description.getText().toString().indexOf("\n\n");
    holder.description.setText(holder.description.getText().toString()
            .substring(0, pos));
    if (!Html.fromHtml(news.content).toString().substring(pos).trim().isEmpty())
        holder.description.append("\n...");
}
 
开发者ID:schul-cloud,项目名称:schulcloud-mobile-android,代码行数:26,代码来源:NewsAdapter.java

示例8: onOptionsItemSelected

import android.text.Html; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected (MenuItem item) {
    if (item.getItemId() == R.id.action_about) {
        TextView textView = new TextView(this);
        int padding = (int) getResources()
                .getDimension(android.support.v7.appcompat.R.dimen.abc_dialog_padding_material);
        textView.setPadding(padding, padding, padding, padding);
        textView.setMovementMethod(LinkMovementMethod.getInstance());
        textView.setText(Html.fromHtml(getString(R.string.about_descr)));
        new AlertDialog.Builder(this)
                .setTitle(R.string.action_about)
                .setView(textView)
                .show();
        return true;
    } else if (item.getItemId() == R.id.action_update) {
        startActivity(new Intent(this, UpdateActivity.class));
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:20,代码来源:MainActivity.java

示例9: onCreate

import android.text.Html; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WizardSPUtils.setShouldShowWizard(false, this);
    SetupWizardLayout layout = new SetupWizardLayout(this);
    layout.getNavigationBar()
            .setNavigationBarListener(this);
    layout.getNavigationBar().getBackButton().setVisibility(View.GONE);
    TextView textView = new TextView(this);
    textView.setText(Html.fromHtml(getString(R.string.wizard_descr_finish)));
    int padding = (int) getResources().getDimension(R.dimen.suw_glif_margin_sides);
    textView.setPadding(padding, padding, padding, padding);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    layout.addView(textView);
    layout.setHeaderText(R.string.app_name);
    setContentView(layout);
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:18,代码来源:FinishWizardActivity.java

示例10: onCustomiseDialog

import android.text.Html; //导入依赖的package包/类
@Override
protected @NonNull DynamicDialog onCustomiseDialog(@NonNull DynamicDialog alertDialog,
                                                   @Nullable Bundle savedInstanceState) {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_about,
            new LinearLayout(getContext()), false);
    TextView message = view.findViewById(R.id.dialog_about_text);

    message.setText(Html.fromHtml(getString(R.string.about_content)
            .replace("\n", "<br/>")));
    message.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE);
    message.setLineSpacing(0f, 1.2f);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setLinkTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));

    alertDialog.setView(view);
    return alertDialog;
}
 
开发者ID:pranavpandey,项目名称:dynamic-dialogs,代码行数:18,代码来源:AboutDialogFragment.java

示例11: formatSingleMotionEvent

import android.text.Html; //导入依赖的package包/类
private Spanned formatSingleMotionEvent(String event, MotionEvent me) {
    StringBuilder sb = new StringBuilder();

    sb.append("<h2>");sb.append(event);sb.append("</h2>");

    sb.append("<p>");
    sb.append("<b>X:</b> ");sb.append(me.getX());
    sb.append("</p>");
    sb.append("<p>");
    sb.append("<b>Y:</b> ");sb.append(me.getY());
    sb.append("</p>");
    sb.append("<p>");
    sb.append("<b>Pressure:</b> ");sb.append(me.getPressure());
    sb.append("</p>");
    //me.get...

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return Html.fromHtml(sb.toString(),Html.FROM_HTML_MODE_LEGACY);
    }
    else {
        return Html.fromHtml(sb.toString());
    }
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:24,代码来源:GestureDetectorActivity.java

示例12: showBigNotification

import android.text.Html; //导入依赖的package包/类
private void showBigNotification(Bitmap bitmap, NotificationCompat.Builder mBuilder, int icon, String title, String message, String timeStamp, PendingIntent resultPendingIntent, Uri alarmSound) {
    NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
    bigPictureStyle.setBigContentTitle(title);
    bigPictureStyle.setSummaryText(Html.fromHtml(message).toString());
    bigPictureStyle.bigPicture(bitmap);
    Notification notification;
    notification = mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
            .setAutoCancel(true)
            .setContentTitle(title)
            .setContentIntent(resultPendingIntent)
            .setSound(alarmSound)
            .setStyle(bigPictureStyle)
            .setWhen(getTimeMilliSec(timeStamp))
            .setSmallIcon(R.drawable.ic_launcher)
            .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
            .setContentText(message)
            .build();

    NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(AppPrefs.NOTIFICATION_ID_BIG_IMAGE, notification);
}
 
开发者ID:NarendraSickarwar,项目名称:FirebasePost,代码行数:22,代码来源:NotifactionUtil.java

示例13: initActivityCreated

import android.text.Html; //导入依赖的package包/类
@Override
protected void initActivityCreated() {
    if (!isPrepared || !isVisible || isLoad) {
        return;
    }

    mAdapter = new XRecyclerViewAdapter<>();

    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    recyclerView.setLoadingMore(this);
    recyclerView.setAdapter(
            mAdapter.setLayoutId(R.layout.item_k567)
                    .onXBind((holder, position, movieModel) -> {
                        holder.setTextView(R.id.k567_item_tv, Html.fromHtml(movieModel.title));
                        ImageLoaderUtils.display(holder.getImageView(R.id.k567_item_iv), movieModel.url);
                    })
                    .setOnItemClickListener((view, position, info) -> K567DetailActivity.startIntent(info.title, info.detailUrl, info.url))
    );

    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.post(this::onRefresh);

    setLoad();
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:26,代码来源:K567ListFragment.java

示例14: onCreate

import android.text.Html; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!WizardSPUtils.shouldShowWizard(this)) {
        startActivity (new Intent(this,
                MainActivity.class));
        finish();
        return;
    }
    SetupWizardLayout layout = new SetupWizardLayout(this);
    layout.getNavigationBar()
            .setNavigationBarListener(this);
    TextView textView = new TextView(this);
    textView.setText(Html.fromHtml(getString(R.string.service_not_running_faq)));
    int padding = (int) getResources().getDimension(R.dimen.suw_glif_margin_sides);
    textView.setPadding(padding, padding, padding, padding);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    layout.addView(textView);
    layout.setHeaderText(R.string.wizard_title_start_fail);
    layout.getNavigationBar().getNextButton().setVisibility(View.GONE);
    setContentView(layout);
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:23,代码来源:StartFailFAQActivity.java

示例15: setCurrentProject

import android.text.Html; //导入依赖的package包/类
public void setCurrentProject(FolderModel folder) {
    String projectNameStr = "";
    double distance = 0;
    double pathDistance = 0;
    if (folder != null) {
        distance = folder.getOverallDistance();
        pathDistance = folder.getPathDistance();
        projectNameStr = folder.getName();
    } else {
        projectNameStr = getString(R.string.none_text);
    }
    if (projectName != null) {
        projectName.setText(projectNameStr);
    }
    if (overallDistance != null) {
        String distanceStr = DistanceUtil.getDistanceString(getContext(), distance);
        String pathDistanceStr = pathDistance == 0 ?
                getString(R.string.overall_path_distance_none) :
                DistanceUtil.getDistanceString(getContext(), pathDistance);
        String overallDistanceStr = getString(R.string.overall_distance_text, distanceStr, pathDistanceStr);
        overallDistance.setText(Html.fromHtml(overallDistanceStr));
    }
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:24,代码来源:NavigationDrawerFragment.java


注:本文中的android.text.Html类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。