I am a beginner Android programmer.
I am creating a shop dialog for a little android game. Then decided to make each shop item a custom view/Group of views. I successfully made a class for it but am unable to show it in my xml layout file. When the shop dialog turns on, everything crashes.
custom view class:
public class ShopItem extends RelativeLayout {
public ShopItem(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.shopcustomvielayout, this);
}
}
Yes, I know that I should not use AbsoluteLayout, but since I am using a dialog it scales perfectly (it doesn't scale at all) and is most comfortable for my current purposes.
And here is the code I use in my dialog/shop layout file.
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#E8E8E8"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true">
<view class="com.example.Example.MyActivity$ShopItem"
android:id="@+id/ShopItem1"
android:layout_width="fill_parent"
android:layout_height="56dp"
android:layout_x="5dp" android:layout_y="40dp"/>
</AbsoluteLayout>
All the other code I have should work perfectly fine, since I wrote it previously and it worked just fine.
I have been struggling for 3 days, can someone PLEASE HELP ME?
Thank you very much to everyone that helped me, I was able to figure out m porblem and my stupid mistake.