Getgravity не сообщает правильное значение в слушателе onclick

У меня есть элемент управления textview, который был добавлен динамически с прослушивателем onclick. Слушатель вызывает метод getgravity textview, который работает с первого клика. Затем пользователь изменяет гравитацию textview на другое значение. Это работает, когда текстовое представление перемещается в родительском представлении, как и ожидалось. При втором щелчке getgravity по-прежнему сообщает исходное значение. Кто-нибудь может выделить проблему для меня?

Код следующим образом

text_Overlay.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View text_Overlay)
        {
            //Toast.makeText(MyActivity.this,"Overlay Clicked",Toast.LENGTH_SHORT).show();
            //Create the dialog intent
            Intent displayTextPropertiesDialog = new Intent(MyActivity.this, DisplayDialogTextProperties.class);
            Bundle dialogBundle = new Bundle();
            dialogBundle.putInt("ID", text_Overlay.getId()); //Your id

            //TextView lclTextView = (TextView) text_Overlay;
            //This also shows the same behaviour as the original line above
            TextView lclTextView = (TextView) findViewById(text_Overlay.getId());
            //String text = lclTextView.getText().toString();

            //TODO: The gravity on a second click is not reporting as expected
            dialogBundle.putInt("hGravity", getHorizGravity(lclTextView.getGravity()));
            dialogBundle.putInt("vGravity", getVertGravity(lclTextView.getGravity()));
            //TO DO: BUG HERE as cant pass colour across yet its a view not a textview and so has no textcolour
            //Handled by casting to TextView in other routine
            dialogBundle.putInt("Colour", getTextColor(text_Overlay.getId()));
            displayTextPropertiesDialog.putExtras(dialogBundle);
            //startActivity(displayTextPropertiesDialog);
            startActivityForResult(displayTextPropertiesDialog, TEXT_PROPERTIES);
        }
    }

0 ответов

Другие вопросы по тегам