0

how call how call this view from my java code for show the white line

<View
    android:id="@+id/linea"
    android:layout_width="fill_parent"
    android:layout_height="1dip"
    android:background="#ffffff" />

this is onCreate

View line;
line = (View) findViewById(R.id.linea);

when select the button

    boton.setOnClickListener(new OnClickListener() 
             {

                 @Override
                 public void onClick(View v) 
                 {

 if(tipoo == 0){
                         double gr[] = con.Peso(y);
                     text1.setText(gr[0] + " kg\n\n"+ line+  gr[1]+ " gramos\n\n" + line+  +gr[2] +
                             " onzas\n\n"+gr[3]+" libras\n\n" + line+   +gr[4]+" Toneladas");
                     }
}

to separate with lines the text from on java code example

Hola ----------- (this is the view of xml code) hi

" text\n"+ (line) +"text"+

I have bad english sorry :(

2
  • it's better, you can use listView then automatically shows your data in every single row... Commented Feb 23, 2014 at 15:52
  • or if you still want to do this using View then you have created at-least 4 View object in your xml file . Commented Feb 23, 2014 at 15:54

2 Answers 2

1

Try this First import import android.view.View; then write this line in your onCreate () method

 View v = (View)findViewById(R.id.linea);

But it is not important to make an object ( of this View) for visibility . without any object a View would visible in your layout.

Sign up to request clarification or add additional context in comments.

3 Comments

But I need call 3 line more of the java code when the client select a button
then first you need a Button object and set the setOnClickListner() method .. post your java code please
that is the java code I need a line over every \n on the text
0

Add View into your activity after setcontentview(R.layout.layout)

 View v = (View)findViewById(R.id.linea);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.