viewgroup

Android Custom Layout - onDraw() never gets called

白昼怎懂夜的黑 提交于 2019-11-27 11:26:27
public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TableView tv = new TableView(this); tv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); setContentView(tv); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } public class TableView extends ViewGroup { private Paint oval; private RectF rect; public TableView(Context context) { super(context); oval= new Paint(Paint.ANTI_ALIAS_FLAG); oval

Difference between View and ViewGroup in Android

拈花ヽ惹草 提交于 2019-11-27 10:50:20
What is the difference between a View and a ViewGroup in Android programming? saibaba vali View View objects are the basic building blocks of User Interface(UI) elements in Android. View is a simple rectangle box which responds to the user's actions. Examples are EditText , Button , CheckBox etc.. View refers to the android.view.View class, which is the base class of all UI classes. ViewGroup ViewGroup is the invisible container. It holds View and ViewGroup For example, LinearLayout is the ViewGroup that contains Button(View), and other Layouts also. ViewGroup is the base class for Layouts.

Android ViewGroup crash: Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference

末鹿安然 提交于 2019-11-27 10:41:02
问题 We have found several cases for this kind of crashes reported by backend logging monitoring. It seems the crashes do not tie to particular UX failure. And from the reports, there is no sign of how our own classes being involved(no sign of any of our classes names). Here is an example of typical crashes: java.lang.NullPointerException: Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3357) at android

ViewGroup finish inflate event

丶灬走出姿态 提交于 2019-11-27 03:26:19
问题 I have created a custom layout which extends ViewGroup. Everything is working fine and I am getting the layout as expected. I want to dynamically change an element in the layout. However this is not working as I am calling it in onCreate and till that time the entire layout is not actually (drawn) inflated onto the screen and hence do not have actual size. Is there any event which can be used to find out when the inflation of the layout is done? I tried onFinishInflate but that would not work

Loop through all subviews of an Android view?

梦想的初衷 提交于 2019-11-27 00:43:12
问题 I’m working on a game for Android. To help implement it, my idea is to create a subclass of a view. I would then insert several instances of this class as children of the main view. Each instance would handle detecting when it was pressed (via OnTouchListener). The problem I’m having now is how do I loop through all these sub-views so I can read their statuses and process them? (I.e. when they all reach a certain state something should happen). Or is there a better way to have several objects

Preventing/catching “IllegalArgumentException: parameter must be a descendant of this view” error

丶灬走出姿态 提交于 2019-11-26 18:38:49
I have a ListView with some focusable components inside (mostly EditText s). Yeah, I know this isn't exactly recommended, but in general, almost everything is working fine and the focus goes where it has to go (with a few tweaks I had to code). Anyway, my problem is that there's a weird race condition when scrolling the list with your finger and then suddenly using the trackball when the IME keyboard is being displayed . Something must go out of bounds and get recycled at which point the offsetRectBetweenParentAndChild() method must kick in and throw the IllegalArgumentException . The problem

Difference between View and ViewGroup in Android

走远了吗. 提交于 2019-11-26 15:20:28
问题 What is the difference between a View and a ViewGroup in Android programming? 回答1: View View objects are the basic building blocks of User Interface(UI) elements in Android. View is a simple rectangle box which responds to the user's actions. Examples are EditText , Button , CheckBox etc.. View refers to the android.view.View class, which is the base class of all UI classes. ViewGroup ViewGroup is the invisible container. It holds View and ViewGroup For example, LinearLayout is the ViewGroup

Android Custom Layout - onDraw() never gets called

醉酒当歌 提交于 2019-11-26 12:11:13
问题 public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TableView tv = new TableView(this); tv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); setContentView(tv); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } public class TableView extends ViewGroup { private Paint oval; private RectF

Preventing/catching “IllegalArgumentException: parameter must be a descendant of this view” error

落花浮王杯 提交于 2019-11-26 06:29:13
问题 I have a ListView with some focusable components inside (mostly EditText s). Yeah, I know this isn\'t exactly recommended, but in general, almost everything is working fine and the focus goes where it has to go (with a few tweaks I had to code). Anyway, my problem is that there\'s a weird race condition when scrolling the list with your finger and then suddenly using the trackball when the IME keyboard is being displayed . Something must go out of bounds and get recycled at which point the