欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Android實(shí)現(xiàn)記事本功能(26)-創(chuàng)新互聯(lián)

本文實(shí)例為大家分享了Android實(shí)現(xiàn)記事本功能的具體代碼,供大家參考,具體內(nèi)容如下

為城陽等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及城陽網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、城陽網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

MainActivity.java代碼:

package siso.smartnotef.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import siso.smartnotef.R;
import siso.smartnotef.adapter.NotepadeAdapter;
import siso.smartnotef.db.DataHelper;
import siso.smartnotef.global.GlobalParams;
import siso.smartnotef.model.NotepadBean;
import siso.smartnotef.model.NotepadWithDataBean;
import siso.smartnotef.service.MainService;

public class MainActivity extends AppCompatActivity implements View.OnClickListener, NotepadeAdapter.ClickFunction {

 private TextView tv_add;
 private ListView lv_contents;
 private List<NotepadWithDataBean> notepadWithDataBeanList;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  Intent intent1 = new Intent(MainActivity.this, MainService.class);
  startService(intent1);
  findViews();
  setListeners();
  initView();

 }

 private void findViews() {
  tv_add = (TextView) findViewById(R.id.tv_add);
  lv_contents = (ListView) findViewById(R.id.lv_content);
 }

 private void setListeners() {
  tv_add.setOnClickListener(this);
 }

 private void initView() {
  DataHelper helper = new DataHelper(MainActivity.this);
  notepadWithDataBeanList = new ArrayList<NotepadWithDataBean>();
  List<NotepadBean> notepadBeanList = helper.getNotepadList();
  for (int i = 0; i < notepadBeanList.size(); i++) {
   if (0 == notepadWithDataBeanList.size()) {
    NotepadWithDataBean notepadWithDataBean = new NotepadWithDataBean();
    notepadWithDataBean.setData(notepadBeanList.get(0).getDate());
    notepadWithDataBeanList.add(notepadWithDataBean);
   }
   boolean flag = true;
   for (int j = 0; j < notepadWithDataBeanList.size(); j++) {
    int date = notepadWithDataBeanList.get(j).getData();
    if (date == notepadBeanList.get(i).getDate()) {
     notepadWithDataBeanList.get(j).getNotepadBeenList().add(notepadBeanList.get(i));
     flag = false;
     break;
    }
   }
   if (flag) {
    NotepadWithDataBean notepadWithDataBean = new NotepadWithDataBean();
    notepadWithDataBean.setData(notepadBeanList.get(i).getDate());
    notepadWithDataBeanList.add(notepadWithDataBean);
    notepadWithDataBeanList.get(notepadWithDataBeanList.size() - 1).getNotepadBeenList().add(notepadBeanList.get(i));
   }
  }
  NotepadeAdapter adapter = new NotepadeAdapter(MainActivity.this, notepadWithDataBeanList, this);
  lv_contents.setAdapter(adapter);
//  setListViewHeightBasedOnChildren(lv_contents);
 }

 public void setListViewHeightBasedOnChildren(ListView listView) {
  if (listView == null) return;
  ListAdapter listAdapter = listView.getAdapter();
  if (listAdapter == null) {
   // pre-condition
   return;
  }
  int totalHeight = 0;
  for (int i = 0; i < listAdapter.getCount(); i++) {
   View listItem = listAdapter.getView(i, null, listView);
   listItem.measure(0, 0);
   totalHeight += listItem.getMeasuredHeight();
  }
  ViewGroup.LayoutParams params = listView.getLayoutParams();
  params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
  listView.setLayoutParams(params);
 }

 @Override
 public void onClick(View v) {
  switch (v.getId()) {
   case R.id.tv_add:
    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    bundle.putInt(GlobalParams.TYPE_KEY, GlobalParams.TYPE_ADD);
    intent.putExtras(bundle);
    intent.setClass(MainActivity.this, AddContentActivity.class);
    startActivityForResult(intent, GlobalParams.ADD_REQUEST);
    break;
  }
 }

 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  switch (requestCode) {
   case GlobalParams.ADD_REQUEST:
    if (GlobalParams.ADD_RESULT_OK == resultCode) {
     initView();
    }
    break;
  }
 }

 @Override
 public void clickItem(int position, int itemPosition) {
  Bundle bundle = new Bundle();
  bundle.putInt(GlobalParams.TYPE_KEY, GlobalParams.TYPE_EDIT);
  bundle.putSerializable(GlobalParams.BEAN_KEY, notepadWithDataBeanList.get(position));
  bundle.putInt(GlobalParams.ITEM_POSITION_KEY, itemPosition);
  Intent intent = new Intent(this, AddContentActivity.class);
  intent.putExtras(bundle);
  startActivityForResult(intent, GlobalParams.ADD_REQUEST);
 }

 @Override
 public void longClickItem(final int position, final int itemPostion) {
  AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
  builder.setMessage("確認(rèn)刪除嗎?");
  builder.setTitle("提示");
  builder.setPositiveButton("確認(rèn)", new DialogInterface.OnClickListener() {
   @Override
   public void onClick(DialogInterface dialog, int which) {
    DataHelper helper = new DataHelper(MainActivity.this);
    helper.deleteNotepad(notepadWithDataBeanList.get(position).getNotepadBeenList().get(itemPostion).getId());
    initView();
   }
  });
  builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
   @Override
   public void onClick(DialogInterface dialog, int which) {
    dialog.dismiss();
   }
  });
  builder.create().show();
 }
}

文章名稱:Android實(shí)現(xiàn)記事本功能(26)-創(chuàng)新互聯(lián)
當(dāng)前地址:http://aaarwkj.com/article38/cojspp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計(jì)公司、關(guān)鍵詞優(yōu)化品牌網(wǎng)站設(shè)計(jì)、微信小程序App開發(fā)、自適應(yīng)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化
日本一区二区三区加勒比| 亚洲男人av天堂东京热 | 成人性生交大片免费男同| 97视频在线中文字幕| 成人黄色动漫在线播放| 我要看黄色一级性生活片| 深夜视频在线观看成人| 国产亚洲成人精品一区| 国产精品免费视频能看的| 国产极白丝白浆日本国产| 亚洲精品入口一区二区| 欧美成人精品资源在线观看| 日本中文字幕乱码一区| 最新国产激情福利网站| 欧美黑人在线一区二区| 丁香六月五月色婷婷网| 久久热在线视频精品视频| 婷婷色中文字幕综合在线| 国产精品夫妇在线激情啪| 香蕉视频欧美久久精品| 亚洲精品另类中文字幕| 欧美日本国产老熟女视频| 每日更新中文字幕粉嫩av| 亚洲欧美日韩精品一区二| 国产伦国产一区二区三区在线观看| 午夜精品视频免费91| 亚洲性码不卡视频在线| 久久精品国产亚洲av热老太| 国产精品一区二区免费式| 久久热最新免费观看视频| 亚洲成年人黄色在线观看| 亚洲少妇熟女一区二区三区| 丝袜在线美腿视频网站| 国产日韩精品综合一区| 国产白丝免费在线观看| 看夫妻性生活免费视频| 国产裸体无遮挡免费精品| 成人一区二区三区观看| 国产男女在线视频观看| 高颜值紧身牛仔裤国产精品| 国产精品视频不卡免费看|