2017-09-25 98 views
0

一週前,我成功地使用了ListView,每次點擊一個按鈕時都會添加一個項目。然後我發現我需要把東西放在一個線程separate from the main UI thread,並在某個地方的某個地方,一些東西壞了。我打破了Android Studio嗎?

現在,我每次啓動Android Studio時都會看到一個錯誤,並說FileNotFoundException: Entry fileTemplates//code/Google Test Fixture SetUp Method.cc.ft not found in E:/Programs/Android Studio/lib/idea.jar儘管我轉到了該文件夾,但我可以看到該文件存在。 This是我最想弄清楚如何解決它。

我也嘗試了我的電腦和手機的冷啓動,重新安裝Android Studio,創建一個全新的項目,以及File> Invalidate Caches and Restart,這些都沒有幫助。

我能找到的唯一答案就是因爲它是32位系統上的64位版本。我確信情況並非如此,除非我特意下載64位而專門查找32位。

我不知道這是Android Studio的問題,Gradle,與我用作測試平臺的手機有什麼關係,或者是什麼。

我使用:

的Windows 8.1專業版(32位)

2X奔騰3.2 GHz的(64)

的Android 2.3.3工作室

API 15的最低SDK :Android 4.0.3 IceCreamSandwich

Java v1.8.0_144(根據命令提示符中的「java -version」)

的Java 8更新60和144都在我安裝的程序列表中,使用Java SE開發工具包8個更新60和144


下面是我所提到的新項目中的代碼一起:

MainActivity的.java

import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.ArrayAdapter; 
import android.widget.ListView; 
import java.util.ArrayList; 

public class MainActivity extends AppCompatActivity { 
    ArrayList<String> listItems; 
    ArrayAdapter<String> adapter; 
    ListView listview = (ListView) findViewById(R.id.listview); 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     listItems = new ArrayList<>(); 
     adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems); 
     listview.setAdapter(adapter); 
    } 

    public void sendAnother(View view) { 
     adapter.add("button clicked"); 
    } 
} 

activity_main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="meh.myapplication.MainActivity"> 

    <Button 
     android:id="@+id/button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="16dp" 
     android:text="Testing" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" /> 

    <ListView 
     android:id="@+id/listview" 
     android:layout_width="0dp" 
     android:layout_height="431dp" 
     android:layout_marginBottom="8dp" 
     android:layout_marginTop="8dp" 
     app:layout_constraintBottom_toTopOf="@+id/button" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" /> 
</android.support.constraint.ConstraintLayout> 
+1

通過在其中編寫代碼實際上破壞IDE幾乎是不可能的。 –

+0

這就是我的想法,但上週工作仍然不起作用。 – donutguy640

+0

@GabeSechan - 通過「寫」確定,但執行的代碼可以做任何事情,如刪除或覆蓋文件。雖然 – Krease

回答

0

事實證明,我所做的一切都是在嘗試在onCreate()之前初始化listview。聲明它是好的,但初始化會打破它。我猜,儘管在xml中定義,View對象直到運行時才被實例化?

我有一個備份,我曾經做過任何破產之前,但它也被打破。或者,現在我再次搞砸了,部分破碎了。 (按鈕不起作用,但我可以輸出到列表視圖)我想這意味着在Android Studio 可能已被打破。我想這就是爲什麼我沒有注意到我嘗試初始化listview的區別。

我猜如果你用錘子敲足夠長的時間,任何岩石都會破裂,呃?

+2

啊,是的,謝謝你downvote沒有理由,非常有幫助。無論你是誰,我都希望你把你的腳趾頭割下。硬。這就是爲我解決這個問題的方法,沒有人會費心回答。 – donutguy640

+0

我對那些評論這個問題的人表示歉意。你可能沒有「回答」,但你是有幫助的,我感謝你。 – donutguy640

+1

感謝您的回答。這可能不是具有類似問題的人想要的,但發生這種情況。因此你的答案肯定有用(+1)。 –