HorizontalScrollView的配置
package com.exmple.jinritoutiao;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import com.exmple.apa.BaseApalistce;
import com.exmple.apa.MyFrgAdapter;
import com.exmple.frage.Fragment_1;
import com.exmple.frage.Fragment_2;
import com.exmple.help.MyHelp;
import com.exmple.jinritoutiao.R;
import com.exmple.listvo.ListVo;
import com.slidingmenu.lib.SlidingMenu;
import Night1.Night;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
public class FuctionActivity extends FragmentActivity implements
OnClickListener {
/** 自定义HorizontalScrollView */
private HorizontalScrollView scvi;
LinearLayout line;
LinearLayout ll_more_columns;
RelativeLayout rl_column;
private ViewPager mViewPager;
private ImageView button_more_columns;
/** 新闻分类列表 */
/** 当前选中的栏目 */
int wit;
private List<TextView> tv_list;
private List<Fragment> listf;
public static boolean blFlag = false;
// 侧滑左侧的图片
int[] imageview = new int[] { R.drawable.dynamicicon_leftdrawer,
R.drawable.topicicon_leftdrawer,
R.drawable.ic_action_favor_on_pressed,
R.drawable.activityicon_leftdrawer,
R.drawable.sellicon_leftdrawer,
R.drawable.feedbackicon_leftdrawer, };
// 侧滑左侧的图片
String[] name = new String[] { "好友动态", "我的话题", "收藏", "活动", "商城", "反馈" };
private String[] columnData1 = new String[] { "推荐", "视频", "社会", "娱乐", "科技",
"汽车", "体育", "军事", "美女", "趣图" };
public static String str;
public static ImageView image;
private SlidingMenu menu;
private ListView listview;
private List<ListVo> list2;
private TextView text;
public static WindowManager window;
private SharedPreferences sp;
private final static String DAY = "day";
private final static String NIGHT = "night";
private Night nig;
private Editor ed;
private SQLiteDatabase sql;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fuction);
MyHelp myHelp = new MyHelp(FuctionActivity.this, "navs", null, 1);
sql = myHelp.getWritableDatabase();
// private int flage = 0;
window = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
// 加载布局文件
initView();
// 得到屏幕的宽度
WindowManager wm = getWindowManager();
wit = wm.getDefaultDisplay().getWidth();
// 找到图片
image = (ImageView) findViewById(R.id.top_head);
// 侧滑的方法
getSlidemenu();
listview = (ListView) findViewById(R.id.listview);
getImage();
getfra();
// horscoiview的配置
tv_list = new ArrayList<TextView>();
for (int i = 0; i < columnData1.length; i++) {
TextView text = new TextView(FuctionActivity.this);
text.setPadding(20, 10, 20, 10);
text.setText(columnData1[i]);
line.addView(text);
tv_list.add(text);
text.setTag(i);
text.setOnClickListener(this);
sql.execSQL("insert into nav values (?,?)", new String[] { null,
columnData1[i] });
}
BaseApalistce ba = new BaseApalistce(FuctionActivity.this, list2);
listview.setAdapter(ba);
FragmentManager fm = getSupportFragmentManager();
mViewPager.setAdapter(new MyFrgAdapter(fm, listf));
mViewPager.setCurrentItem(0);
setQTextColor(0);
mViewPager.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int arg0) {
setQTextColor(arg0);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
// TODO Auto-generated method stub
}
@Override
public void onPageScrollStateChanged(int arg0) {
// TODO Auto-generated method stub
}
});
}
private void getSlidemenu() {
menu = new SlidingMenu(FuctionActivity.this);
menu.setMode(SlidingMenu.LEFT);
/* menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); */
// menu.setTouchModeAbove(SlidingMenu.SLIDING_WINDOW);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
// 设置策划的宽度
menu.setShadowWidth(200);
menu.setBehindOffset(150);
// 绑定Activity
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setFadeDegree(0.35f);
menu.setMenu(R.layout.cehua);
ImageView setting = (ImageView) findViewById(R.id.setting);
ImageView night = (ImageView) findViewById(R.id.night);
text = (TextView) findViewById(R.id.day);
// 白天,黑夜的切换
sp = this.getSharedPreferences("skinchange", Context.MODE_PRIVATE);
String mode = sp.getString("skin", "");
nig = new Night(window, FuctionActivity.this);
if (mode != null || !mode.equals("")) {
if (mode.equals(NIGHT)) {
nig.night();
} else {
nig.day();
}
}
// 创建商品对象
SharedPreferences sha1 = getSharedPreferences("num", MODE_APPEND);
ed = sha1.edit();
night.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences sha2 = getSharedPreferences("num",
MODE_APPEND);
int flage = sha2.getInt("aa", 0);
if (flage % 2 == 0) {
nig.night();
text.setText("白天模式");
text.setTextColor(Color.WHITE);
flage++;
} else {
nig.day();
text.setText("夜间模式");
text.setTextColor(Color.BLACK);
flage++;
}
ed.putInt("aa", flage);
ed.commit();
}
});
ImageView qq = (ImageView) findViewById(R.id.qq);
ImageView webo = (ImageView) findViewById(R.id.webo);
TextView login = (TextView) findViewById(R.id.login);
ImageView down = (ImageView) findViewById(R.id.down);
down.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent ints = new Intent(FuctionActivity.this,
DownActivity.class);
startActivityForResult(ints, 11);
overridePendingTransition(R.anim.slide_right, R.anim.slide_left);
}
});
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent ints = new Intent(FuctionActivity.this,
LoginMoreActivity.class);
startActivityForResult(ints, 2);
overridePendingTransition(R.anim.slide_right, R.anim.slide_left);
}
});
webo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ThridLogin.getViBo(FuctionActivity.this);
}
});
qq.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ThridLogin.getThrid(FuctionActivity.this);
}
});
setting.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent ints = new Intent(FuctionActivity.this,
SettingActivity.class);
startActivityForResult(ints, 1);
overridePendingTransition(R.anim.slide_right, R.anim.slide_left);
}
});
image.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (menu.isMenuShowing() == false) {
menu.showMenu(true);
} else {
menu.showMenu(false);
}
}
});
}
/*
* public void night4(View view) { SharedPreferences preferences =
* getSharedPreferences("default_night", MODE_PRIVATE); Editor editor =
* preferences.edit(); if (blFlag) {
* this.setTheme(R.style.BrowserThemeNight); blFlag = false;
* editor.putBoolean("default_night", false); } else {
* this.setTheme(R.style.BrowserThemeDefault); blFlag = true;
* editor.putBoolean("default_night", true);
*
* } // 提交修改 editor.commit();
* this.setContentView(R.layout.activity_fuction); }
*/
// 为侧滑左侧配置数据
private List<ListVo> getImage() {
list2 = new ArrayList<ListVo>();
for (int i = 0; i < imageview.length; i++) {
ListVo li = new ListVo();
li.setImageview(imageview[i]);
li.setText(name[i]);
list2.add(li);
}
return list2;
}
// 为fragemetn配置数据
private List<Fragment> getfra() {
listf = new ArrayList<Fragment>();
for (int i = 0; i < columnData1.length; i++) {
Fragment_2 f2 = new Fragment_2();
// bundle传值
Bundle bundle = new Bundle();
bundle.putString("text", columnData1[i]);
/* Fragment_1 f1 = new Fragment_1(url[i]); */
f2.setArguments(bundle);
listf.add(f2);
}
return listf;
}
private void setQTextColor(int p) {
TextView textView = tv_list.get(p);
for (int i = 0; i < tv_list.size(); i++) {
TextView text = tv_list.get(p);
int k = text.getMeasuredWidth();
int l = text.getLeft();
int s = k / 2 + l - wit / 2;
scvi.smoothScrollTo(s, 0);
TextView t = tv_list.get(i);
if (!t.equals(textView)) {
t.setTextColor(Color.BLACK);
} else {
t.setTextColor(Color.RED);
}
}
}
private void initView() {
// 找控件
scvi = (HorizontalScrollView) findViewById(R.id.mColumnHorizontalScrollView);
// HorizontalScrollView里的线性
line = (LinearLayout) findViewById(R.id.mRadioGroup_content);
ll_more_columns = (LinearLayout) findViewById(R.id.ll_more_columns);
rl_column = (RelativeLayout) findViewById(R.id.rl_column);
button_more_columns = (ImageView) findViewById(R.id.button_more_columns);
mViewPager = (ViewPager) findViewById(R.id.mViewPager);
button_more_columns.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(FuctionActivity.this, "我是添加频道的", 0).show();
}
});
}
@Override
public void onClick(View v) {
int i = (Integer) v.getTag();
/* System.out.println(columnData[i]); */
for (int j = 0; j < tv_list.size(); j++) {
/*
* Toast.makeText(FuctionActivity.this, (CharSequence)
* tv_list.get(j), 0).show();
*/
mViewPager.setCurrentItem(i);
}
}
}
HorizontalScrollView的配置的更多相关文章
- Android ListView滚动条配置完全解析
滚动条的相关显示效果 先来看下ListView的滚动条有哪些显示效果. 滚动条自身的外观 这点不用说,就是滚动条自身的颜色,形状等. Track的外观 默认的ListView是没有设置Track的.为 ...
- 配置android sdk 环境
1:下载adnroid sdk安装包 官方下载地址无法打开,没有vpn,使用下面这个地址下载,地址:http://www.android-studio.org/
- Android Studio配置 AndroidAnnotations——Hi_博客 Android App 开发笔记
以前用Eclicps 用习惯了现在 想学学 用Android Studio 两天的钻研终于 在我电脑上装了一个Android Studio 并完成了AndroidAnnotations 的配置. An ...
- react-router 组件式配置与对象式配置小区别
1. react-router 对象式配置 和 组件式配置 组件式配置(Redirect) ----对应---- 对象式配置(onEnter钩子) IndexRedirect -----对应-- ...
- 总结:Mac前端开发环境的搭建(配置)
新年新气象,在2016年的第一天,我入手了人生中第一台自己的电脑(大一时好友赠送的电脑在一次无意中烧坏了主板,此后便不断借用别人的或者网站的).macbook air,身上已无分文...接下来半年的房 ...
- Android Studio 多个编译环境配置 多渠道打包 APK输出配置
看完这篇你学到什么: 熟悉gradle的构建配置 熟悉代码构建环境的目录结构,你知道的不仅仅是只有src/main 开发.生成环境等等环境可以任意切换打包 多渠道打包 APK输出文件配置 需求 一般我 ...
- Virtual Box配置CentOS7网络(图文教程)
之前很多次安装CentOS7虚拟机,每次配置网络在网上找教程,今天总结一下,全图文配置,方便以后查看. Virtual Box可选的网络接入方式包括: NAT 网络地址转换模式(NAT,Network ...
- [linux]阿里云主机的免登陆安全SSH配置与思考
公司服务器使用的第三方云端服务,即阿里云,而本地需要经常去登录到服务器做相应的配置工作,鉴于此,每次登录都要使用密码是比较烦躁的,本着极速思想,我们需要配置我们的免登陆. 一 理论概述 SSH介绍 S ...
- nginx配置反向代理或跳转出现400问题处理记录
午休完上班后,同事说测试站点访问接口出现400 Bad Request Request Header Or Cookie Too Large提示,心想还好是测试服务器出现问题,影响不大,不过也赶紧上 ...
随机推荐
- iOS 时间戳
时间戳用过一回,总结一下: 1.在Terminal下获得时间戳: date +%s 原来要在服务器端挂文档,方便开发商下载,用时间戳作为文件名称来区分. 2.在程序下获得时间戳: NSDate * n ...
- 简述C#中关键字var和dynamic的区别
C#中关键字var和dynamic的区别如下: 1.var申明的变量必须初始化,dynamic申明的变量无需初始化. 2.var关键字只能在方法内部申明局部变量,dynamic关键字可用于局部变量,字 ...
- Fast and Robust Hand Tracking Using Detection-Guided Optimization
http://handtracker.mpi-inf.mpg.de/projects/FastHandTracker/
- ionic环境搭建和安装
1. 安装node环境 nodeJs环境的安装很简单,去官网下载最新版的NodeJs直接安装即可. Node官网: https://nodejs.org/ 安装完成后配置环境变量,计算机->属性 ...
- webstorm注册
选择“license server” 输入:http://114.215.133.70:41017(适用ws2016.2.2) 2.3选择activation code注册 43B4A73YYJ-ey ...
- Buffer too small
在项目中用到了CString,后来发现在Format的时候会报Buffer too small的错误,在网上查资料发现时这样的 CString output ; int size = m_NicInf ...
- APICloud十一月线下活动(杭州、上海)
阿里云创业大学 ——APICloud/银杏谷移动课堂[杭州站] 时间:2015年11月28日13:30-16:30 地点:文三路华星时代广场A座3楼银杏谷1024孵化器 主办:APICloud.阿里云 ...
- poi导出Excel报表多表头双层表头、合并单元格
效果图: controller层方法: /** * * 导出Excel报表 * @param request * @return * */ @ ...
- js转换 /Date(1464671903000)/ 格式的日期的方法
转换成:2016-07-11 function getFDate(date) { var d = eval('new ' + date.substr(1, date.length - 2)); var ...
- CGCS2000 VS WGS84