3

I posted some answers for readers here: How to write a custom filter for ListView with ArrayAdapter

On my last post, I was trying to add xml. In the end I added it as an image, as it kept being interpreted, although I tried to add it as a code block. Any advice on adding xml inline please?

Also, I added a large code block (in a code fragment) and it got broken up. Some is displayed as text, some in a scrolling window (as it should be).

Would someone be able to check my post and advise please?

2
  • possible duplicate of How do I format my code blocks?
    – Jon Seigel
    Mar 23, 2011 at 16:56
  • 1
    You format xml just like code blocks, which you are able to do. But you have more problems. You're treating StackOverflow like a forum--you have three answers in that question; you should only have one. Also, you've dumped tons of code and xml in your answers. You should only put relevant lines in. Editing down your answers is very important for readability.
    – user1228
    Mar 23, 2011 at 17:00

2 Answers 2

1

When there are blank spaces in the beginning of some lines pasted from some IDE it might mess things up - four spaces means "parse this line as code block".

Usually selecting the whole block and clicking the code icon in the editor or pressing CTRL+K will fix this, I tried with your last block and the preview show it should work - give this a try and see for yourself.

Same goes for XML - are you sure you're using the correct icon? It's looks like this: {}

1

Here's a fragment of XML like yours that doesn't get munged:

<?xml version="1.0" encoding="utf-8">
<LinearLayout xmlns:android="xxx"
    android:foo="yyy"
    android:bar="zzz"
    <TextView blah="asdf" />    
</LinearLayout>

I just pasted this in, selected the code, then hit the {} icon. Look at the source of this answer to see the text formatting/indentation.

2
  • Nice, I've made it look like XML as well by adding <!-- language: lang-xml --> - see the edit source. :) Mar 25, 2011 at 9:16
  • @Shadow - Thanks for the tip and the edit!
    – bstpierre
    Mar 25, 2011 at 12:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .