編輯:關於Android編程
#3F51B5 #303F9F #FF4081 #ffffff #fffff0 #ffffe0 #ffff00 #fffafa #fffaf0 #fffacd #fff8dc #fff5ee #fff0f5 #ffefd5 #ffebcd #ffe4e1 #ffe4c4 #ffe4b5 #ffdead #ffdab9 #ffd700 #ffc0cb #ffb6c1 #ffa500 #ffa07a #ff8c00 #ff7f50 #ff69b4 #ff6347 #ff4500 #ff1493 #ff00ff #ff00ff #ff0000 #fdf5e6 #fafad2 #faf0e6 #faebd7 #fa8072 #f8f8ff #f5fffa #f5f5f5 #f5f5dc #f5deb3 #f4a460 #f0ffff #f0fff0 #f0f8ff #f0e68c #f08080 #eee8aa #ee82ee #e9967a #e6e6fa #e0ffff #deb887 #dda0dd #dcdcdc #dc143c #db7093 #daa520 #da70d6 #d8bfd8 #d3d3d3 #d3d3d3 #d2b48c #d2691e #cd853f #cd5c5c #c71585 #c0c0c0 #bdb76b #bc8f8f #ba55d3 #b8860b #b22222 #b0e0e6 #b0c4de #afeeee #adff2f #add8e6 #a9a9a9 #a9a9a9 #a52a2a #a0522d #9932cc #98fb98 #9400d3 #9370db #90ee90 #8fbc8f #8b4513 #8b008b #8b0000 #8a2be2 #87cefa #87ceeb #808080 #808080 #808000 #800080 #800000 #7fffd4 #7fff00 #7cfc00 #7b68ee #778899 #778899 #708090 #708090 #6b8e23 #6a5acd #696969 #696969 #66cdaa #6495ed #5f9ea0 #556b2f #4b0082 #48d1cc #483d8b #4682b4 #4169e1 #40e0d0 #3cb371 #32cd32 #2f4f4f #2f4f4f #2e8b57 #228b22 #20b2aa #1e90ff #191970 #00ffff #00ffff #00ff7f #00ff00 #00fa9a #00ced1 #00bfff #008b8b #008080 #008000 #006400 #0000ff #0000cd #00008b #000080 #000000
ZNDJ 感謝使用本app 關於 新聞 聊天 測試 Hello blank fragment
package com.example.swing.zndj; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * Created by swing on 2016/9/16. */ public class ChatFragment extends Fragment { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.layout_chat,null); return view; } }
package com.example.swing.zndj; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class NewsFragment extends Fragment{ @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.layout_news,null); return view; } }
package com.example.swing.zndj; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * Created by swing on 2016/9/16. */ public class TestFragment extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.layout_test,null); } }
package com.example.swing.zndj; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.RadioButton; import android.widget.TextView; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity implements View.OnClickListener { private Toolbar toolbar; private ViewPager viewpager; private Listfragmentlist; private RadioButton tag_1, tag_2, tag_3; private RecyclerView left_dawer; private TextView right_dawer; private DrawerLayout drawerLayout; private String[] data ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); findviewbyid(); initData(); init(); clicked(); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu,menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { if (drawerLayout.isDrawerOpen(right_dawer)){ drawerLayout.closeDrawer(right_dawer); }else{ if (drawerLayout.isDrawerOpen(left_dawer)){ drawerLayout.closeDrawer(left_dawer); } drawerLayout.openDrawer(right_dawer); } return true; } /* findviewbyid */ public void findviewbyid() { toolbar = (Toolbar) findViewById(R.id.toolbar); viewpager = (ViewPager) findViewById(R.id.viewpager); tag_1 = (RadioButton) findViewById(R.id.tag_1); tag_2 = (RadioButton) findViewById(R.id.tag_2); tag_3 = (RadioButton) findViewById(R.id.tag_3); drawerLayout = (DrawerLayout) findViewById(R.id.drawerlayout); left_dawer = (RecyclerView) findViewById(R.id.left_drawer); right_dawer = (TextView) findViewById(R.id.right_drawer); } /* 原始數據的獲取 */ public void initData(){ data = new String[]{"1","2","3","1","2","3","1","2","3"}; } /* 控件初始化 */ public void init() { //toolbar初始化 setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.ic_info); toolbar.setTitle(R.string.app_name); toolbar.setSubtitle(R.string.subtitle); //viewpager初始化 FragmentManager manager = getSupportFragmentManager(); fragmentlist = new ArrayList (); fragmentlist.add(new NewsFragment()); fragmentlist.add(new ChatFragment()); fragmentlist.add(new TestFragment()); viewpager.setAdapter(new MyAdapter(manager, fragmentlist)); //left_dawer初始化 left_dawer.setLayoutManager(new LinearLayoutManager(this)); left_dawer.setAdapter(new MyRecyclerViewAdapter(data)); } /* 控件的監聽器注冊 */ public void clicked() { toolbar.setNavigationOnClickListener(this); tag_1.setOnClickListener(this); tag_2.setOnClickListener(this); tag_3.setOnClickListener(this); viewpager.setOnPageChangeListener(new MyChangeListener(tag_1, tag_2, tag_3)); drawerLayout.setDrawerListener(new MyDrawerLayoutListener()); } /* 點擊監聽器的監聽邏輯(導航按鈕,底部導航) */ @Override public void onClick(View v) { if (v == tag_1) { tag_2.setChecked(false); tag_3.setChecked(false); viewpager.setCurrentItem(0); } else if (v == tag_2) { tag_1.setChecked(false); tag_3.setChecked(false); viewpager.setCurrentItem(1); } else if (v == tag_3) { tag_1.setChecked(false); tag_2.setChecked(false); viewpager.setCurrentItem(2); }else{ if (drawerLayout.isDrawerOpen(left_dawer)){ drawerLayout.closeDrawer(left_dawer); toolbar.setNavigationIcon(R.drawable.ic_info); }else { if (drawerLayout.isDrawerOpen(right_dawer)){ drawerLayout.closeDrawer(right_dawer); } drawerLayout.openDrawer(left_dawer); toolbar.setNavigationIcon(R.drawable.ic_info1); } } } /** *viewpager的適配器類,參數FragmentManager,List */ class MyAdapter extends FragmentPagerAdapter { List fragmentList = new ArrayList<>(); public MyAdapter(FragmentManager fm, List fragmentList) { super(fm); this.fragmentList = fragmentList; } @Override public Fragment getItem(int position) { return fragmentList.get(position); } @Override public int getCount() { return fragmentList.size(); } } /** *viewpager的頁面選擇監聽器 */ class MyChangeListener implements ViewPager.OnPageChangeListener { RadioButton tag_1, tag_2, tag_3; public MyChangeListener(RadioButton tag_1, RadioButton tag_2, RadioButton tag_3) { this.tag_1 = tag_1; this.tag_2 = tag_2; this.tag_3 = tag_3; } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (position == 0) { tag_1.setChecked(true); tag_2.setChecked(false); tag_3.setChecked(false); } else if (position == 1) { tag_1.setChecked(false); tag_2.setChecked(true); tag_3.setChecked(false); } else if (position == 2) { tag_1.setChecked(false); tag_2.setChecked(false); tag_3.setChecked(true); } } @Override public void onPageSelected(int position) { } @Override public void onPageScrollStateChanged(int state) { } } /** * RecyclerView的適配器類 */ class MyRecyclerViewAdapter extends RecyclerView.Adapter { String[] data; public MyRecyclerViewAdapter(String[] data) { this.data = data; } @Override public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.layout_revyvlerview_item,viewGroup,false); MyViewHolder myviewholder = new MyViewHolder(view); return myviewholder; } @Override public void onBindViewHolder(MyViewHolder myViewHolder, int i) { myViewHolder.textview.setText(data[i]); } @Override public int getItemCount() { return data.length; } class MyViewHolder extends RecyclerView.ViewHolder{ TextView textview; public MyViewHolder(View itemView) { super(itemView); textview = (TextView) itemView.findViewById(R.id.recyclerview_item); } } } /** * drawerlayout開閉狀態監聽器 */ class MyDrawerLayoutListener extends DrawerLayout.SimpleDrawerListener{ @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (drawerView == left_dawer) { toolbar.setNavigationIcon(R.drawable.ic_info1); }else{ //right_drawer判斷 } } @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if (drawerView == left_dawer) { toolbar.setNavigationIcon(R.drawable.ic_info); }else { //right_drawer判斷 } } } }
最近在學Android 學的不好 然後看到了用.9.png寫對話框的哪裡,但是書上寫的太簡單 感覺做出來和書上的不一樣 然後就去各種百度 感覺網上關於這個東西的資料都是粘
引言接Android變形(Transform)之Matrix,來總結下Camera的使用,Camera主要實現3D的變形,有轉動,旋轉等,Camera的源碼是由Nativ
Android Gradle Build Error:Some file crunching failed, see logs for details解決辦法錯誤日志:E
Android React Native 已經將幾個常用的原生組件進行了封裝,比如 ScrollView 和 TextInput,但是並不是所有系統的原始組件都被封裝了,