Snippets

サトミツジムラ RxJava Hello, World!

Created by サトミツジムラ

File helloworld Added

  • Ignore whitespace
  • Hide word diff
+package jp.gr.java_conf.qkuronekop.rxsample;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.widget.TextView;
+
+import rx.Observable;
+
+/**
+ * Created by qkuronekop on 2016/05/26.
+ */
+
+public class SecondActivity extends AppCompatActivity {
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_second);
+
+        String[] hellos = {"Hell,", " World!"};
+
+        Observable.from(hellos)
+                .reduce((p, c) -> {
+                    return p + c;
+                })
+                .subscribe(s -> {
+            ((TextView) findViewById(R.id.second_text_view)).setText(s.toString());
+        });
+
+    }
+}
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.