[Solved] Android – add lines dynamically to layout

use LinearLayout with vertical orientation instead of TextView in xml. Create TextView in Java. each time you get the string from server create new TextView in java and add this into LinearLayout. Here is example code. LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linear_layout_id); TextView tv = new TextView(this); tv.setText(“FirstText”); tv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT)); linearLayout.addView(tv); 1 solved Android – add … Read more

[Solved] Multiple fonts to a single custom TextView

This is how I achieved: Created a custom TextView public class CaptainTextView extends TextView { private HashMap<String, Typeface> mTypefaces; public CaptainTextView(Context context) { super(context); } public CaptainTextView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); super(context, attrs, defStyleAttr); if (mTypefaces == null) { mTypefaces = new HashMap<>(); } if (this.isInEditMode()) { return; } final TypedArray array … Read more

[Solved] how to combine try in the if condition [closed]

Like this: try { if(txtweb.getText().toString().equals(“Google Plus”)) { setContentView(R.layout.google); InputStream is = getAssets().open(“read_asset.txt”); int size = is.available(); byte[] buffer = new byte[size]; is.read(buffer); is.close(); String text = new String(buffer); TextView tv = (TextView)findViewById(R.id.text); tv.setText(text); } else if(txtweb.getText().toString().equals(“Twitter”)){ setContentView(R.layout.google); } } catch (IOException e) { throw new RuntimeException(e); } 2 solved how to combine try in the … Read more

[Solved] How to resolve error “non static method ‘getDeviceId()’ cannot be referenced by static context” [duplicate]

public String getDeviceId(Context context){ TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); return telephonyManager.getDeviceId(); } 4 solved How to resolve error “non static method ‘getDeviceId()’ cannot be referenced by static context” [duplicate]

[Solved] Is any possible preview or run that particular program only in eclipse? [closed]

I believe you are asking whether you could modify your code to run in Eclipse as opposed to emulating an Android system and running it on that. Well, yes, you could (probably) change your code so it runs ‘in Eclipse’, however why would you do that? Then you don’t know if it runs on Android … Read more

[Solved] String type not allowed (at textColor with value ‘black’): Android Studios [closed]

try this <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:textColor=”@color/colorAccent”/> or this <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:textColor=”#ff00″/> or this <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:textColor=”@android:color/black”/> solved String type not allowed (at textColor with value ‘black’): Android Studios [closed]

[Solved] Parsing multidimensional JSON in java

Try to use google GSON Library it will fullfill the same requirements as you want. Here is the Link for a sample tutorial implemented in android how ever the language used is Java All you have to do is make a data model of same type and as members in JSOn. try the example in … Read more

[Solved] App is crashing when I convert string to int

check if its not null then cast to integer: try { if(description[i][j]!=null && description[i][j].length()>0){ id=Integer.parseInt(description[i][j]); Toast.makeText(getApplicationContext(),id, Toast.LENGTH_SHORT).show(); } } instead of try { id=Integer.parseInt(description[i][j]); } i hope its work but description[i][j] must returns string. if id getting value then print toast.otherwise no toast print.. 2 solved App is crashing when I convert string to int

[Solved] send string data from Activity to fragment [closed]

Add below code inside listview itemclick listner in activity: Tozihat gTozihat = new Tozihat().newInstance(“Data”); getSupportFragmentManager().beginTransaction() .replace(R.id.textViewTozihat, gTozihat).commit(); Inside your Fragment : private static final String TYPE = “DATA_KEY”; public static Tozihat newInstance(String type) { Tozihat fragment = new Tozihat(); Bundle args = new Bundle(); args.putString(TYPE, type); fragment.setArguments(args); return fragment; } 3 solved send string data … Read more

[Solved] 2.5D engine on Android? [closed]

Like Wikipedia states, you can either render 2D images on the screen giving the effect of a 3D world. For this I would suggest you have a look at the SurfaceView class on the Android developer site as well as having a look at this Android Game Dev. link If you prefer to rather create … Read more

[Solved] Click on button in MainActivity and go to screen on MainActivity2 [closed]

In your onCreate method, you should do something like this: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(Bundle savedInstanceState); setContentView(R.layout.activity_main); Button btn = findViewById(R.id.your_button_id); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(MainActivity.this, MainActivity2.class)); } } } The your_button_id is the ID of the button in your MainActivity and the code above tells the … Read more