kbiakov / CodeView-Android

Display code with syntax highlighting :sparkles: in native way.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

when i am fetching the string of formatted code from Firebase Realtime database the code showing in a single line.

mRAJENDRAKUMAR-droid opened this issue · comments

###DetailActivity.xml
``

<TextView
    android:id="@+id/textViewrv1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="40dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    android:text="program name sample as login  to firebase"
    android:layout_centerHorizontal="true"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<!-- CODEVIEW  program-->
<RelativeLayout
    android:layout_below="@+id/textViewrv1"
    android:layout_width="match_parent"
    android:layout_marginTop="10dp"
    android:orientation="vertical"
    android:layout_height="match_parent">


   <io.github.kbiakov.codeview.CodeView
       android:id="@+id/code_view_text"
       android:layout_width="match_parent"
       android:layout_height="match_parent"></io.github.kbiakov.codeview.CodeView>
</RelativeLayout>

DetailActivity.java

package com.rajendra.firebaseproject.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.rajendra.firebaseproject.R;
import io.github.kbiakov.codeview.CodeView;
import io.github.kbiakov.codeview.adapters.Options;
import io.github.kbiakov.codeview.classifier.CodeProcessor;
import io.github.kbiakov.codeview.highlight.ColorTheme;
public class DetailActivity extends AppCompatActivity {

String pname,pcontent;
TextView rvpname;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    pname = getIntent().getExtras().getString("sendPNAME");
    pcontent = getIntent().getExtras().getString("sendPCONTENT");
    rvpname =findViewById(R.id.textViewrv1);
    rvpname.setText(pname);
    CodeProcessor.init(this);
    CodeView codeView = (CodeView) findViewById(R.id.code_view_text);
    //codeView.setCode(pcontent, "c");

    codeView.setOptions(Options.Default.get(this)
            .withLanguage("c")
            .withCode(pcontent)
            .withTheme(ColorTheme.MONOKAI));


}

}

but the ans is showing like this screenshots :

image

Add linebreaks (\n) to your code

Thats made by firebase just change it to \n again

This Issue can be marked as closed