Android基礎環境搭建

來源:互聯網
上載者:User

標籤:

?

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????自動格式化代碼

註:如果快速鍵失效,請關閉搜狗IME的全域熱鍵。

????

?

由於很久沒有開啟過開發環境了:

居然不知多了一個fragment.xml的配置,調試的時候總是提示有問題:

在網上找到一個經驗:

?

  1. 將帶有fragment_***.xml的檔案刪除;
  2. 開啟對應的Activity,將ActionBarActivity替換為Activity;
  3. 去除PlaceholderFragment整個類

?

修改之前:

  1. publicclass TestActivity extendsActionBarActivity {
  2. ?
  3. [email protected]
  4. ???protectedvoid 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. [email protected]
  15. ???publicboolean 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. ??????returntrue;
  20. ???}
  21. ?
  22. [email protected]
  23. ???publicboolean 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. ?????????returntrue;
  30. ??????}
  31. ??????returnsuper.onOptionsItemSelected(item);
  32. ???}
  33. ?
  34. ???/**
  35. ????* A placeholder fragment containing a simple view.
  36. ????*/
  37. ???publicstaticclassPlaceholderFragment extends Fragment {
  38. ?
  39. ??????public PlaceholderFragment() {
  40. ??????}
  41. ?
  42. [email protected]
  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. publicclass TestActivity extends Activity {
  2. ?
  3. [email protected]
  4. ???protectedvoid onCreate(Bundle savedInstanceState) {
  5. ??????super.onCreate(savedInstanceState);
  6. ??????setContentView(R.layout.activity_test);
  7. ???}
  8. ?
  9. [email protected]
  10. ???publicboolean 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. ??????returntrue;
  15. ???}
  16. ?
  17. [email protected]
  18. ???publicboolean 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. ?????????returntrue;
  25. ??????}
  26. ??????returnsuper.onOptionsItemSelected(item);
  27. ???}
  28. }

?

Android基礎環境搭建

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.