DevStore首页 > DEV资源 > 源码下载 > 源码详情

仿知乎日报UI

 
zhengjiajian | 2015-06-15 18:17    浏览量(7326)    评论(5)    收藏(28)
功能分类:新闻 支持平台:Android 运行环境:Eclipse
开发语言:Java 开发工具:Eclipse 源码大小:5.39MB
下载源码 1012 人下载

源码简介

仿知乎日报的UI界面,里面添加了下拉刷新,侧栏动画可以看看。

源码截图

  • 运行截图
  • 运行截图
  • 运行截图
DevStore所有源码来自用户上传分享,版权问题及牵扯到商业纠纷均与DevStore无关。

源码片段

package com.lan.nicehair.activity;

import android.app.ActivityGroup;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;
import android.widget.TabWidget;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

import com.lan.nicehair.R;
import com.lan.nicehair.R.id;
import com.lan.nicehair.R.layout;
import com.zdp.aseo.content.AseoZdpAseo;


@SuppressWarnings("deprecation")
public class MainActivity extends ActivityGroup {
	@InjectView(R.id.tabhost) TabHost mTabHost;
	@InjectView(R.id.radiogroup) RadioGroup mRadioGroup;
	@InjectView(R.id.layout_comment) LinearLayout mLayoutComment;
	@InjectView(R.id.post_comment_input) EditText mEditInput;
	@OnClick(R.id.post_input_camera)
	public void onPostCameraClicked(View v) {
		
	}
	@OnClick(R.id.post_input_send)
	public void onPostSendClicked(View v) {
		
	}
	public static final String CLICK_RECEIVED_ACTION="click_action";
	private ActionClickReceiver mActionClickReceiver;
	private InputMethodManager mInputManager;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		ButterKnife.inject(this);
		mTabHost.setup(getLocalActivityManager());
		final TabWidget tabWidget = mTabHost.getTabWidget(); 
        tabWidget.setStripEnabled(false);// 圆角边线不启用 
		addTabIntent();
		mTabHost.setCurrentTab(0);
		mInputManager=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
		mRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub
				switch(checkedId) {
				case R.id.radio_choumeibang:
					mTabHost.setCurrentTab(0);
					break;
				case R.id.radio_hairscan:
					mTabHost.setCurrentTab(1);
					break;
				case R.id.radio_discover:
					mTabHost.setCurrentTab(2);
					break;
				case R.id.radio_me:
					mTabHost.setCurrentTab(3);
					break;
				}
			}
		});
		registerMessageReceiver();
	}
	public void registerMessageReceiver() {
		mActionClickReceiver = new ActionClickReceiver();
		IntentFilter filter = new IntentFilter();
		filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
		filter.addAction(CLICK_RECEIVED_ACTION);
		registerReceiver(mActionClickReceiver, filter);
	}
	public class ActionClickReceiver extends BroadcastReceiver {
		
		@Override
		public void onReceive(Context context, Intent intent) {
			if (CLICK_RECEIVED_ACTION.equals(intent.getAction())) {
				int uid=intent.getIntExtra("uid", 0);
				mLayoutComment.setVisibility(View.VISIBLE);
				mInputManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
				mEditInput.requestFocus();
			}
		}
	}
	@Override  
	public boolean dispatchKeyEvent(KeyEvent event) {  
		if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN )
		{
			Intent intent = new Intent(Intent.ACTION_MAIN);
			intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			intent.addCategory(Intent.CATEGORY_HOME);
			AseoZdpAseo.initFinalTimer(this);
			startActivity(intent);
			return true;
		}
		return super.dispatchKeyEvent(event);
	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		if(mActionClickReceiver!=null)
			unregisterReceiver(mActionClickReceiver);
	}
	private TabHost.TabSpec buildTabSpec(String tag,String m,
			final Intent content) {
		return this.mTabHost
				.newTabSpec(tag).setIndicator(m)
				.setContent(content);
	}
	private void addTabIntent() {
		this.mTabHost.addTab(buildTabSpec("tab1","0",new Intent(this,ZoneActivity.class)));
		this.mTabHost.addTab(buildTabSpec("tab2","1",new Intent(this,FindHairActivity.class)));
		this.mTabHost.addTab(buildTabSpec("tab3","2",new Intent(this,DisCoverActivity.class)));
		this.mTabHost.addTab(buildTabSpec("tab4","3",new Intent(this,MeActivity.class)));
	}
}
  •   赞(2) 赞 +1 赞(2) 已赞
  •   收藏(28) 收藏 +1 已收藏 取消
  •   下载(1012)
评论(5)
Molik

Molik 2016-01-23 02:10:09

正好需要谢谢分享呀
回复(0) 赞(0) 赞(1)
lvxb

lvxb 2015-06-18 10:55:59

正好需要谢谢分享呀
回复(0) 赞(0) 赞(1)
crazy1235

crazy1235 2015-06-17 09:07:21

LOW,界面简单,bug很多、
回复(0) 赞(0) 赞(1)
q21940

q21940 2015-06-16 14:11:09

不错的UI,谢谢
回复(0) 赞(0) 赞(1)
lvxb

lvxb 2015-06-16 12:32:20

不错的UI,谢谢
回复(0) 赞(0) 赞(1)
  • 推荐
  • 审核
  • 收录
  • 获取活力值

源码上传作者

  • 122 能力值
  • 59 源码
  • 0 评测
  • 0 资料

热门源码