您好我有一個ListView和我試圖從開始通過列表視圖的活動的活動{startActivity(class.java);}開始從一個ListView
進口android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView;
public class ll2 extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] myList = new String[] {"Accrington Stanley", "Aldershot Town", "Barnet", "Bradford City", "Burton Albion", "Bury", "Cheltenham Town", "Chesterfield", "Crewe A", "Gillingham", "Hereford Utd", "Lincoln City", "Macclesfield T", "Morecombe", "Northampton T", "Oxford Utd", "Port Vale", "Rotherham Utd", "Shrewsbury T", "Southend Utd", "Stevenage", "Stockport C", "Torquay Utd", "Wycombe W"};
ListView lv = new ListView(this);
lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,myList));
setContentView(lv); }
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
if ("Bradford City".equals(MyList()[position]))
{startActivity(Bradford.java);}
}
}
我得到一個誤差與此行,如果( 「布拉德福德」 .equals(MYLIST()[位置]))方法myList中()是未定義的類型LL2
我曾嘗試而各種的方法,我不能得到任何工作。我想要做的就是爲列表中的每個團隊提供一個單獨的java文件(Class)隨着他們的活動,幫助我在我的智慧結束。
What MyList()???你是從哪裏複製和粘貼的?它似乎是一種返回你的列表視圖的方法,但你沒有放置定義。 – Aliostad 2010-09-24 11:48:41
myList涉及到String [] myList [] {「accrington行這個listactivity從這裏複製:http://www.vogella.de/articles/Android/article.html但我已經改變,並試圖添加一個活動 – JonniBravo 2010-09-24 12:20:40
MyList?檢查案例,你已經將它聲明爲myList ... – Shouvik 2010-09-24 12:21:21