Is it possible to set a listener for only part of the user view?

I want to create a custom view (extends View) that contains an image and text.

Is it possible to set a listener only for an image if I use the method canvas.drawBitmap(imageBitmap, ...)?

Thank!

+3
source share
1 answer

If you want your view to display only image and text, why not create a specific layout in your XML file and use it setContentViewto display the view?

If this is what you were looking for, I think this is the easiest approach. XML example coming soon.

, , , , , TextView ImageView.

dblist.xml res/layout.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:background="#FFFFFF">
<ListView android:id="@+id/list"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:textColor="#000000"/>
</LinearLayout>

Spinner

, :

setContentView(R.layout.dblist);

, ,

setContentView(R.layout.main);

EDIT:

findViewById , . dblist.xml, , ListView list. :

ListView myList = (ListView) findViewById(R.id.list);

, , - XML , myList .

, .

+1

Source: https://habr.com/ru/post/1730777/


All Articles