java

关注公众号 jb51net

关闭
首页 > 软件编程 > java > java实现收藏名言语句台词的app

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

投稿:hebedich

本文给大家分享的是使用java制作的记录名人名言台词等等让你难忘的语句的APP的代码,非常的实用,有需要的小伙伴可以参考下。

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

/**
  * 创建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有所帮助。

您可能感兴趣的文章:
阅读全文