所以我想在我的應用程序有哪些包含媒體播放器,所以我希望把對準該列表視圖項的「播放」圖標幾個項目在右邊。列表視圖項目包含圖像視圖和文本視圖(均具有項目圖標和項目名稱)。 有什麼辦法我可以插入圖片到特定項目希望把「播放」圖標一些列表視圖項
這裏是我的代碼:
first.java:
public class first extends AppCompatActivity {
private ListView listView;
private String[] names = {"१. प्रार्थना",
"२. सुखकर्ता दु:खहर्ता",
"३. गजानना श्रीगणराया",
"४. येई हो विठ्ठले",
"५. लवथवती विक्राळा",
"६. दुर्गे दुर्घट भारी",
"७. आरती ज्ञानराजा",
"८. हे भोळ्या शंकरा",
"९. ओवाळू आरती",
"१०. मंगेशा महारूद्रा",
"११. आला गणराया",
"१२. शेंदुर लाल चढायो",
"१३. एकदंता",
"१४. कर्पूर गौरा",
"१५. हे गजवधना",
"१६. प्रथमेश्वरा",
"१७. जयदेवा हे साईनाथा",
"१८. श्री सत्यनारायणाची आरती",
"१९. श्री महालक्ष्मीची आरती",
"२०. ॐ जय लक्ष्मी माता",
"२१. आरती संतोषी माता की",
"२२. श्री हनुमंताची आरती",
"२३. सुखंकर्ता की दु:खहर्ता",
"२४. ॐ जय जगदीश",
"२५. जय श्री विश्वकर्मा",
"२६. हे गौरी गजानन",
"२७. हे गजानना गौरीनंदना",
"२८. आरती नवदुर्गेची",
"२९. हे साईनाथा जगदिश्वरा",
"३०. धन्य धन्य हो प्रदक्षिणा",
"३१. घालीन लोटांगण"};
private int imageid[] = {R.drawable.prath,
R.drawable.ganeshaji,
R.drawable.ganpati,
R.drawable.vita,
R.drawable.shivji,
R.drawable.durgamaa,
R.drawable.nyan,
R.drawable.bol,
R.drawable.krishna,
R.drawable.mangeshi,
R.drawable.ala,
R.drawable.shen,
R.drawable.ekdant,
R.drawable.karpur,
R.drawable.gajavad,
R.drawable.pratha,
R.drawable.saibaba,
R.drawable.satyanarayan,
R.drawable.laxmimaa,
R.drawable.omjailak,
R.drawable.santoshimaa,
R.drawable.hanuman,
R.drawable.ganeshaji,
R.drawable.skd,
R.drawable.vishwakarma,
R.drawable.ganpati,
R.drawable.ganeshaji,
R.drawable.navdurga,
R.drawable.saibaba,
R.drawable.danya,
R.drawable.gana};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setIcon(R.mipmap.icon);
final CustomList CustomList = new CustomList(this, names, imageid);
listView = (ListView) findViewById(R.id.listView);
listView.setAdapter(CustomList);
}
}
arti.java:
public class arti {
private String names;
private int imageid;
public arti(String names,int imageid){
this.names=names;
this.imageid=imageid;
}
public String getNames(){
return this.names;
}
public int getImageid(){
return this.imageid;
}
}
customlist。 java:
public class CustomList extends ArrayAdapter<String> {
private String[] names;
private int[] imageid;
private Activity context;
public CustomList(Activity context, String[] names, int[] imageid) {
super(context, R.layout.list_layout,names);
this.context = context;
this.names = names;
this.imageid = imageid;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.list_layout, null, true);
TextView textViewName = (TextView) listViewItem.findViewById(R.id.textViewName);
ImageView image = (ImageView) listViewItem.findViewById(R.id.imageView);
textViewName.setText(names[position]);
image.setImageResource(imageid[position]);
return listViewItem;
}
first.xml:
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView"
android:dividerHeight="2dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="1dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
listlayout.xml:
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/imageView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="80dp"
android:gravity="center"
android:textSize="22dp"
android:text="New Text"
android:id="@+id/textViewName"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
我想表演圖像放置的物品
是行不通@sumandas – Devk
@Devk什麼錯誤或問題,或者問題? – sumandas
我希望將「播放」圖標放在項目名稱後面。 – Devk