2013-07-30 29 views
0

這裏是編碼r無法得到解決 - 在Eclipse中的錯誤,並佈置爲Android

package com.st.accounts; 
import android.app.Activity; 
import android.content.ContentValues; 
import android.database.sqlite.SQLiteDatabase; 
import android.os.Bundle; 
import android.util.Log; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.widget.EditText; 
import android.widget.Toast; 



public class AddAccount extends Activity { 

@Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     setContentView(R.layout.addaccount);// error occurs here r is not resolved 
    } 


@Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     return Utils.inflateMenu(this,menu); 
    } 

    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     return Utils.handleMenuOption(this,item); 
    } 

    public void addAccount(View v) { 
     // get access to views 
     EditText editAcno = (EditText) this.findViewById(R.id.editAcno); 
     EditText editCno = (EditText) this.findViewById(R.id.editCno); 
     EditText editHolders = (EditText) this.findViewById(R.id.editHolders); 
     EditText editBankName = (EditText) this.findViewById(R.id.editBankName); 
     EditText editBranchName = (EditText) this.findViewById(R.id.editBranchName); 
     EditText editAddress = (EditText) this.findViewById(R.id.editAddress); 
     EditText editIFSC = (EditText) this.findViewById(R.id.editIFSC); 
     EditText editMICR = (EditText) this.findViewById(R.id.editMICR); 
     EditText editBalance = (EditText) this.findViewById(R.id.editBalance); 
     EditText editRemarks = (EditText) this.findViewById(R.id.editRemarks); 


     } 


    } 

}

它迫切傢伙,請整理出來儘快

我已經看到了一些以前關於這個帖子,但它並沒有幫助我,我嘗試了其中的一些,但 setContentView(R.layout.addaccount) 仍然有主錯誤

所以你們能解決它嗎?

+1

你有什麼嘗試,所以我們不給你建議,不工作?首先要做的是檢查每個xml文件,包括'manifest.xml',並確保沒有任何錯誤。然後點擊「Project - > Clean ...」清理項目 – codeMagic

+0

你可以發佈addaccount.xml – buczek

+0

你是否重構過任何東西,或者弄亂了包?看一看'R.java':'Project Folder - > gen - > package name - > R.java',看看有沒有什麼不對的地方 –

回答

0

你是否在你的文件中導入了R類? ,因爲我沒有在您的導入中看到它。

應該是這樣的代碼:

import com.st.acccounts.R 

import com.st.R 

根據您的應用程序包。

,或只是將鼠標懸停在R其中,在文件中出現的錯誤,然後單擊導入R.

之後嘗試和清潔 - 再建立自己的項目,我相信,這將是確定。 GLP。

GL。

0

如果您正在Eclipse IDE中開發,那麼在某些XML文件中可能會有一些錯誤導入res文件夾。修復它們,如果問題仍然存在,請執行以下操作:Project -> Clean

0

您需要檢查R.java是否存在,如果不存在,則應找出原因。

0

如果Project> Clean不起作用,請嘗試創建一個新項目並將代碼/資源複製到新項目中。這總是爲我解決了這個問題。

相關問題