-1
我一直在尋找很長時間,仍然沒有找到任何解決方案。 我想要的是,當你點擊這個自定義列表項目https://prnt.sc/flwqe3之一,當你點擊它時,每個列表項都有他自己的意圖。基於陣列列表項目中的位置的多種不同意圖
如果有人知道答案請讓我知道。
這是與自定義listItems中的activty
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout._main);
//Set the titel of the actionbar
TextView actionbartitel = (TextView) findViewById(R.id.actionbar_titel);
Typeface = Typeface.createFromAsset(getAssets(), "fonts/.ttf");
actionbartitel.setTextSize(30);
actionbartitel.setTypeface();
actionbartitel.setText("");
//set the back button of the actionbar
ImageView actionbarimage = (ImageView) findViewById(R.id.actionbar_logo);
actionbarimage.setImageResource(R.drawable.ic_arrow_back_white_24dp);
// Set a click listener on that View
actionbarimage.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the family category is clicked on.
@Override
public void onClick(View view) {
// Create a new intent to open the {@link FamilyActivity}
Intent mainIntent = new Intent(Activity.this, MainActivity.class);
// Start the new activity
startActivity(mainIntent);
}
});
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId(getResources().getString(R.string.interstitial_ad_unit_id));
AdRequest adRequest = new AdRequest.Builder().build();
interstitial.loadAd(adRequest);
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
displayInterstitial();
}
});
ListView listView = (ListView) findViewById(R.id.list);
ArrayList<Subjects> = new ArrayList<Subjects>();
.add(new Subjects("", "", R.mipmap.ic_launcher, "5:60", 0xff00ffff,
Typeface.createFromAsset(getAssets(), "fonts/Font.ttf"), Typeface.createFromAsset(getAssets(), "fonts/timeFont.ttf")));
.add(new Subjects("", " " + System.getProperty("line.separator") + " ", R.mipmap.ic_launcher, "5:60", 0xff0000ff,
Typeface.createFromAsset(getAssets(), "fonts/Font.ttf"), Typeface.createFromAsset(getAssets(), "fonts/timeFont.ttf")));
WordAdapter adapter = new WordAdapter(this, list);
listView.setAdapter(adapter);
}
public void displayInterstitial() {
if (interstitial.isLoaded()) {
View loadingIndicator = findViewById(R.id.classicmprogressbar);
loadingIndicator.setVisibility(View.GONE);
interstitial.show();
}
}
}
我編輯的主體,並添加類的列表項 – anomynous
最終WordAdapter適配器=新WordAdapter(這一點,obsclassiclist); listView.setAdapter(adapter); listView.setOnItemClickListener(新ListView.OnItemClickListener(){ @覆蓋 公共無效onItemClick(適配器視圖>父,觀景,INT位置,長的id){ //創建一個新的意圖打開{@link FamilyActivity} 意向mainIntent =新意圖(ObsclassicActivity.this,adapter.getItem(位置).CLS); //啓動新活動 startActivity(mainIntent);} 時 – anomynous
點擊我仍然沒有happends有不正確的東西我的聽衆 – anomynous