Question: I have the following jQuery code:

```
$('#foo').click(function ()  {
    var loading = $('<img id="loading" src="images/loader.gif" alt="loading" />');
    $('#stars').prepend(loading);
    alert('WAIT');
});

$('#bar').click(function ()  {
     $('#stars').empty();
});

```

When first clicking `#foo` the image is being shown in my browser window. After clicking `#bar` and then `#foo` again the image is not being shown.

I use Chrome and also use the `Inspect Element` tool and I can see in the code that the `img` tag was added in `#stars` when clicking for the second time `#foo`. But no `img` is being shown in the browser window.

Any ideas why? Should I use the `live()` function perhaps, but how?

Answer: 
`onMeasure()` is usually called during layout phase. Besides as far as I know `onMeasure()` is where *YOU* have to measure your view. It receives 2 values which are the size of the parent of your view which may be constant.

Why don't you just check the length of the text you're setting and if it's too long just replace it with your default one?
You will want to implement `Textwatcher` and in the `onTextChanged(...)` method, call `TextView`'s [setEms(...)](http://developer.android.com/reference/android/widget/TextView.html#setEms%28int%29) method, which will set the width of the `TextView` to the width of (n *m*'s), where n is the input for `setEms(...)`. 

```
...
TextView tv = (TextView) findViewById(R.id.my_text_view);
tv.addTextChangedListener(this);
...
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
    tv.setEms(count);
}

```