小编Nit*_*tin的帖子

如何从android中的非活动类调用片段

我有一个Login Fragment和一个名为CServerResponse的类.

我想LoginFragmentCServerResponse课堂上打电话.

我怎样才能做到这一点?

这是CServerResponse类代码:

public class CServerResponse {
    public static CServerResponse s_m_oServerResponse;
    public Context m_Context;

    private CServerResponse(Context m_Context) {
        this.m_Context = m_Context;
    }

    public static CServerResponse getInstance() {
        if (s_m_oServerResponse == null) {
            s_m_oServerResponse = new CServerResponse();
        }
        return s_m_oServerResponse;
    }

    public void getLoginResponse() throws JSONException {
        final Fragment activity = (Fragment) m_Context;
        if (CLoginScreen.m_oResponseobject.getString("resultdescription").equalsIgnoreCase("Transaction Successful")) {

            CLoginScreen.m_oLoginSession.setLoginData(
                CLoginScreen.s_szResponseMobile, CLoginScreen.s_szResponsePassword);

            getActivity().getSupportFragmentManager()
                         .beginTransaction()
                         .replace(R.id.container, new CDealMainListing()).commit();

            CToastMessage.getInstance().showToast(getActivity(), "You are successfully Logged …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-activity

2
推荐指数
1
解决办法
6700
查看次数

如何在android的单例类中制作进度条

我有一个单独布局的进度条,我想在单例类中实现进度条,并在所有框架中使用单例类的方法。我该怎么做。

这是我的progressbar.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="wrap_content"
            android:layout_height="65dp"
            android:background="#43A6F3"
            android:orientation="vertical">

<TextView
    android:id="@+id/progress_text"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_above="@+id/progress_bar"
    android:layout_marginLeft="10dp"
    android:layout_marginStart="10dp"
    android:background="@android:color/transparent"
    android:gravity="center_vertical"
    android:text=""
    android:textColor="@android:color/white"
    android:textSize="16sp"
    android:visibility="gone" />

<ProgressBar
    android:id="@+id/progress_bar"
    style="@android:style/Widget.DeviceDefault.Light.ProgressBar.Horizontal"
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_gravity="center"
    android:background="#FFFF"
    android:maxHeight="20dp"
    android:minHeight="20dp" />
Run Code Online (Sandbox Code Playgroud)

这是我的单身课程

public class CShowProgress {
public static CShowProgress s_m_oCShowProgress;
public static Context m_Context;
public Dialog m_Dialog;
public ProgressBar m_ProgressBar;

public CShowProgress(Context m_Context) {
    this.m_Context = m_Context;

}

public static CShowProgress getInstance() {
    if (s_m_oCShowProgress == null) {
        s_m_oCShowProgress = new CShowProgress(m_Context);
    }
    return s_m_oCShowProgress;
} …
Run Code Online (Sandbox Code Playgroud)

android

1
推荐指数
1
解决办法
2587
查看次数