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

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在线蜜桃| 亚洲国产日韩精品自拍av| 五月色婷婷六月色丁香| 一区二区中文字幕日本韩国| 精品人妻一区二区三区蜜桃视频| 青青草原在线视频一区| 亚洲中文永久免费视频| 亚洲高清成人在线观看| 亚洲国产av国产av| 国产v精品欧美精品v日韩| 一区二区三区在线观看日本视频| 尤物在线免费观看视频| 日韩欧美啪啪一区二区| 亚洲国产成人精品福利| 欧美一级特黄大片做受| 午夜激情视频在线网站| 国产精品视频不卡免费看| 久久精品亚洲av三区麻豆| 激情五月综合开心五月| 午夜影院在线观看网站| 香蕉夜夜草草久久亚洲香蕉| 免费黄色一区二区三区| 亚洲熟女午夜毛片av毛片| 激情五月婷婷久久激情| 亚洲精品影视一区二区| 亚洲香蕉视频免费在线观看| 精品久久中文字幕久久av| 在线免费观看91亚洲| 亚洲欧美国产成人在线| 91精品在线观看首页| 亚洲欧美丝袜清纯另类| 国产精品日本在线观看| 国产精品国产一级国产av| 亚洲欧美经典精品专区| 青青草青娱乐免费在线视频| 日韩精品中文字幕欧美乱| 色综合久久婷婷色综合网| 日本韩国欧美一区二区在线| 亚洲熟妇中文字幕五十中出|