java实现收藏名言语句台词的app

时间:2021-05-19

让动漫中那些喜欢的人、喜欢的台词,让你难忘的话语,都保留在你的手机中吧

/** * 创建DialogueFragment视图 * */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View v = inflater.inflate(R.layout.fragment_acg_dialogue, container, false); int id = (Integer) getArguments().getSerializable(EXTRA_ACG_ID); mAcg = AcgLab.get(getActivity()).getAcg(id); mDialogueTextView = (TextView) v.findViewById(R.id.dialogue_tv); // 从以下标点符号处换行 String dialogue = mAcg.getDialogue().replace(",", "\n"); dialogue = dialogue.replace("。", "\n"); dialogue = dialogue.replace("?", "\n"); dialogue = dialogue.replace("!", "\n"); mDialogueTextView.setText(dialogue); mPersonageTextView = (TextView) v.findViewById(R.id.personage_tv); if (!mAcg.getPersonage().isEmpty()) { mPersonageTextView.setText("--" + mAcg.getPersonage()); } else { mPersonageTextView.setText(""); } mHeadImageView = (ImageView) v.findViewById(R.id.avatar_iv); mRippleImageView = (ImageView) v.findViewById(R.id.ripple_iv); // 将该应用程序自带的句子和用户添加的句子分开处理 if (mAcg.getId() < AcgListFragment.SYSTEM_DIALODUE_LENGHT) { mHeadImageView.setImageResource(Integer.parseInt(mAcg.getHead())); mHeadImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // 设置水波动画 Animation anim = AnimationUtils.loadAnimation( getActivity(), R.anim.anim_ripple); mRippleImageView.startAnimation(anim); AcgDialogueFragment.getPlayer().play(getActivity(), Integer.parseInt(mAcg.getSound())); } }); } else { // 图片路径不存在或者未设置 File file = new File(mAcg.getHead()); if (mAcg.getHead().isEmpty() || (!file.exists())) { // 设置默认图片 mHeadImageView.setImageResource(R.drawable.saber); } else { Bitmap bmp = PictureUtils.getScaledBitmapFromPath( getActivity(), mAcg.getHead()); bmp = PictureUtils.getRoundBitmap(bmp); mHeadImageView.setImageBitmap(bmp); } mHeadImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // 设置水波动画 Animation anim = AnimationUtils.loadAnimation( getActivity(), R.anim.anim_ripple); mRippleImageView.startAnimation(anim); if (mAcg.getId() < AcgListFragment.SYSTEM_DIALODUE_LENGHT) { AcgDialogueFragment.getPlayer().play(getActivity(), Integer.parseInt(mAcg.getSound())); } else { if (mAcg.getSound().isEmpty()) { Toast.makeText(getActivity(), R.string.tip_not_sound, Toast.LENGTH_SHORT) .show(); } else { AcgDialogueFragment.getPlayer().play(getActivity(), mAcg.getSound()); } } } }); } return v; }

演示图:

以上所述就是本文的全部内容了,希望能够对大家熟练掌握java开发app有所帮助。

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章