This is what the whole thing looks like. The first time I set title,
it works fine (in onCreate). The next time I set it, it works fine (in
searchHandler). The third time when I do it (in reloadHandler), the
click listeners are not registered and the text in the text view does
not change.

I had initially put the code outside handlers in the click listeners.
But that didn;t work either. Also tried calling invalidate() on the
buttons and textview. But that didn't help either.

Thanks.


@Override
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

        getWindow().setFeatureInt
(Window.FEATURE_CUSTOM_TITLE,R.layout.text_title);

        TextView databar = (TextView) findViewById(R.id.search_title_text);
        databar.setText("My Text");

        // Watch for button clicks.
        Button applyButton = (Button) findViewById(R.id.srch_left_btn);
        applyButton.setOnClickListener(mOtherButtonListener);
        applyButton.setText("Some Text");

        Button searchBtn = (Button) findViewById(R.id.srch_right_btn);
        searchBtn.setOnClickListener(searchListener);

}

OnClickListener mOtherButtonListener = new OnClickListener() {
        public void onClick(View v) {
                finish();
        }
};

OnClickListener searchListener = new Button.OnClickListener() {
        public void onClick(View v) {
                searchHandler.sendEmptyMessage(1);
        }
};

Handler searchHandler = new Handler() {

        @Override
        public void handleMessage(Message message) {
                MyClass.this.getWindow().setFeatureInt
(Window.FEATURE_CUSTOM_TITLE,R.layout.search_title);

                final EditText fullSearchField = (EditText) findViewById
(R.id.title_full_search);

                fullSearchField.setOnKeyListener(new OnKeyListener() {
                        public boolean onKey(View v, int keyCode, KeyEvent 
event) {
                                if ((event.getAction() == KeyEvent.ACTION_DOWN)
                                                && (keyCode == 
KeyEvent.KEYCODE_ENTER)) {

                                        String searchTxt = 
fullSearchField.getText().toString();
                                        getSearchResults(searchTxt);
                                        return true;
                                }
                                return false;
                        }
                });

                Button cancelBtn = (Button) MyClass.this.findViewById
(R.id.title_cancel_btn);
                cancelBtn.setOnClickListener(cancelSearchListener);
        }
};

OnClickListener cancelSearchListener = new OnClickListener() {
        public void onClick(View v) {
                reloadHandler.sendEmptyMessage(1);
        }
};

Handler reloadHandler = new Handler() {

        @Override
        public void handleMessage(Message message) {
                MyClass.this.getWindow().setFeatureInt
(Window.FEATURE_CUSTOM_TITLE,R.layout.text_title);

                TextView databar = (TextView) MyClass.this.findViewById
(R.id.search_title_text);
                databar.setText("My Text");

                Button applyButton = (Button) MyClass.this.findViewById
(R.id.srch_left_btn);
                applyButton.setText("Some Text");
                applyButton.setOnClickListener(mOtherButtonListener);

                Button searchBtn = (Button) MyClass.this.findViewById
(R.id.srch_right_btn);
                searchBtn.setOnClickListener(searchListener);

                MyClass.this.reloadOldData();
        }
};
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to