Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;

public class Main {
    public static String replaceStr(Context context, int resId, String... replaces) {
        String result = context.getResources().getString(resId);
        if (isEmpty(result)) {
            return "";
        }

        if (replaces == null || 0 == replaces.length) {
            return result;
        }

        for (int i = 0; i < replaces.length; i++) {
            result = result.replaceFirst("#a#", replaces[i]);
        }

        return result;
    }

    public static boolean isEmpty(String str) {
        if (str == null || str.isEmpty()) {
            return true;
        }
        return false;
    }
}