真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Android中如何實(shí)現(xiàn)一個(gè)時(shí)間軸效果-創(chuàng)新互聯(lián)

本文小編為大家詳細(xì)介紹“Android中如何實(shí)現(xiàn)一個(gè)時(shí)間軸效果”,內(nèi)容詳細(xì),步驟清晰,細(xì)節(jié)處理妥當(dāng),希望這篇“Android中如何實(shí)現(xiàn)一個(gè)時(shí)間軸效果”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來(lái)學(xué)習(xí)新知識(shí)吧。

我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、鹿邑ssl等。為1000多家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的鹿邑網(wǎng)站制作公司

其實(shí)只不過(guò)是布局+動(dòng)態(tài)生產(chǎn)TextView罷了,一開(kāi)始選的是 FrameLayout,后來(lái)發(fā)現(xiàn)在處理單擊事件的時(shí)候一個(gè)問(wèn)題  ,例如:

FrameLayout frameLayout= (FrameLayout) findViewById(R.id.frameLayout);     for(...){         frameLayout.add(tv1);        frameLayout.add(tv2);        //在這里直接處理單擊事件肯定是不行的,tv1和tv2是重合在一起的     }                 FrameLayout frameLayout= (FrameLayout) findViewById(R.id.frameLayout);     for(...){         tv1.setLayoutparams(....);        frameLayout.add(tv1);        frameLayout.add(tv2);       //在這里直接處理單擊事件就可以了,不知道為什么?     }

所以,直接改 成Linearlayout了,改成Linearlayout后,那些TextView的位置也好設(shè)置多了,下面是代碼:

package com.lliq.ui;    import android.app.Activity;       import android.os.Bundle;       import android.util.Log;       import android.view.View;       import android.view.View.OnClickListener;      import android.view.Window;       import android.widget.FrameLayout;       import android.widget.LinearLayout;       import android.widget.TextView;             import com.lliq.R;             public class HistoryActivity extends Activity      {          private final int space_year = 5;           private final int space_month = 5;          private String[] year = { "2010", "2011", "2012", "2013" };          private String[][] month = { { "01", "03", "04", "11" }, { "07" }, { "01", "03", "04", "11" },                  { "07" } };                  boolean menu_falg = false;// 單擊改變菜單圖標(biāo)                  private TextView[] tv_year;          private TextView[] tv_month;           private TextView content;                   @Override          protected void onCreate(Bundle savedInstanceState)           {              super.onCreate(savedInstanceState);              requestWindowFeature(Window.FEATURE_NO_TITLE);               setContentView(R.layout.iq_history);              initLayout();          }                private void initLayout()          {               LinearLayout btnback = (LinearLayout) findViewById(R.id.history_layouthome);               final TextView btnhome = (TextView) findViewById(R.id.history_btnhome);              btnback.setOnClickListener(new OnClickListener()             {                 @Override                 public void onClick(View arg0)                  {                      menu_falg = !menu_falg;                     btnhome.setBackgroundResource(menu_falg ? R.drawable.menuspread : R.drawable.menu_n);                     MainActivity.handler.sendEmptyMessage(0);                  }              });                     content = (TextView) findViewById(R.id.content);              LinearLayout timelayout = (LinearLayout) findViewById(R.id.timelayout);              tv_year = new TextView[year.length];              for (int i = 0; i < year.length; i++)              {                  tv_year[i] = new TextView(this);                  tv_year[i].setPadding(                        10,                          i == 0 ? space_year : space_year                                  * (13 - Integer.parseInt(month[i - 1][month[i - 1].length - 1])), 0, 0);                   tv_year[i].getPaint().setFakeBoldText(true);                 tv_year[i].setTextSize(14);                  tv_year[i].setTag(year[i]);                   tv_year[i].setText(year[i] + "  --");                  tv_year[i].setOnClickListener(new TimeLineClickListener(tv_year[i]));                   timelayout.addView(tv_year[i]);                  tv_month = new TextView[year.length];                  for (int j = 0; j < month[i].length; j++)                  {                      tv_month[i] = new TextView(this);                      if (j == 0)                      {                          tv_month[i].setPadding(20, space_month * Integer.parseInt(month[i][j]), 0, 0);                       } else                     {                          tv_month[i].setPadding(20, space_month                                   * (Integer.parseInt(month[i][j]) - Integer.parseInt(month[i][j - 1])),                                  0, 0);                      }                       tv_month[i].setTextSize(12);                       tv_month[i].setText(month[i][j] + "月   --");                      tv_month[i].setTag(year[i] + "-" + month[i][j]);                       tv_month[i].setOnClickListener(new TimeLineClickListener(tv_month[i]));                     timelayout.addView(tv_month[i]);                  }              }                 }                 class TimeLineClickListener implements OnClickListener           {                     TimeLineClickListener(View v)               {             }                     @Override              public void onClick(View v)               {                   content.setText(v.getTag().toString());              }          }              }

讀到這里,這篇“Android中如何實(shí)現(xiàn)一個(gè)時(shí)間軸效果”文章已經(jīng)介紹完畢,想要掌握這篇文章的知識(shí)點(diǎn)還需要大家自己動(dòng)手實(shí)踐使用過(guò)才能領(lǐng)會(huì),如果想了解更多相關(guān)內(nèi)容的文章,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。


名稱欄目:Android中如何實(shí)現(xiàn)一個(gè)時(shí)間軸效果-創(chuàng)新互聯(lián)
文章分享:http://weahome.cn/article/dicide.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部