Android基础环境搭建

?

1.安装JDK

从官网下载JDK安装,

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

技术分享我选择的如上图红色,为jdk1.8.0_45。

?

安装好JDK之后,会提示安装JRE,请保持安装在同一目录:如均在"Java"目录下

技术分享

?

2.配置环境变量

  1. 新建JAVA_HOME:选择jdk的安装路径,如K:\Java\jdk1.8.0_45

    技术分享

  2. Path中增加:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;

    技术分享

  3. 新建CLASSPATH:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

    技术分享

  4. 验证

    技术分享

    技术分享

    ?

    技术分享

    技术分享

    ?

    java和javac命令都通过,则说明配置好了!

    ?

3.下载ADT

由于不知怎么找到,从百度云盘搜索了一个。

技术分享

?

4.实用工具

Ctr +shift+O 自动添加包

Ctr+/????????注释代码

Ctr+Shit+F????自动格式化代码

注:如果快捷键失效,请关闭搜狗输入法的全局热键。

????技术分享

?

由于很久没有打开过开发环境了:

居然不知多了一个fragment.xml的配置,调试的时候总是提示有问题:

在网上找到一个经验:

?

  1. 将带有fragment_***.xml的文件删除;
  2. 打开对应的Activity,将ActionBarActivity替换为Activity;
  3. 去除PlaceholderFragment整个类

?

修改之前:

  1. public class TestActivity extends ActionBarActivity {
  2. ?
  3. ???@Override
  4. ???protected void onCreate(Bundle savedInstanceState) {
  5. ??????super.onCreate(savedInstanceState);
  6. ??????setContentView(R.layout.activity_test);
  7. ?
  8. ??????if (savedInstanceState == null) {
  9. ?????????getSupportFragmentManager().beginTransaction()
  10. ???????????????.add(R.id.container, new PlaceholderFragment()).commit();
  11. ??????}
  12. ???}
  13. ?
  14. ???@Override
  15. ???public boolean onCreateOptionsMenu(Menu menu) {
  16. ?
  17. ??????// Inflate the menu; this adds items to the action bar if it is present.
  18. ??????getMenuInflater().inflate(R.menu.test, menu);
  19. ??????return true;
  20. ???}
  21. ?
  22. ???@Override
  23. ???public boolean onOptionsItemSelected(MenuItem item) {
  24. ??????// Handle action bar item clicks here. The action bar will
  25. ??????// automatically handle clicks on the Home/Up button, so long
  26. ??????// as you specify a parent activity in AndroidManifest.xml.
  27. ??????int id = item.getItemId();
  28. ??????if (id == R.id.action_settings) {
  29. ?????????return true;
  30. ??????}
  31. ??????return super.onOptionsItemSelected(item);
  32. ???}
  33. ?
  34. ???/**
  35. ????* A placeholder fragment containing a simple view.
  36. ????*/
  37. ???public static class PlaceholderFragment extends Fragment {
  38. ?
  39. ??????public PlaceholderFragment() {
  40. ??????}
  41. ?
  42. ??????@Override
  43. ??????public View onCreateView(LayoutInflater inflater, ViewGroup container,
  44. ????????????Bundle savedInstanceState) {
  45. ?????????View rootView = inflater.inflate(R.layout.fragment_test, container,
  46. ???????????????false);
  47. ?????????return rootView;
  48. ??????}
  49. ???}
  50. }

修改之后:

  1. public class TestActivity extends Activity {
  2. ?
  3. ???@Override
  4. ???protected void onCreate(Bundle savedInstanceState) {
  5. ??????super.onCreate(savedInstanceState);
  6. ??????setContentView(R.layout.activity_test);
  7. ???}
  8. ?
  9. ???@Override
  10. ???public boolean onCreateOptionsMenu(Menu menu) {
  11. ?
  12. ??????// Inflate the menu; this adds items to the action bar if it is present.
  13. ??????getMenuInflater().inflate(R.menu.test, menu);
  14. ??????return true;
  15. ???}
  16. ?
  17. ???@Override
  18. ???public boolean onOptionsItemSelected(MenuItem item) {
  19. ??????// Handle action bar item clicks here. The action bar will
  20. ??????// automatically handle clicks on the Home/Up button, so long
  21. ??????// as you specify a parent activity in AndroidManifest.xml.
  22. ??????int id = item.getItemId();
  23. ??????if (id == R.id.action_settings) {
  24. ?????????return true;
  25. ??????}
  26. ??????return super.onOptionsItemSelected(item);
  27. ???}
  28. }

?

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。