TextView textView = (TextView)findViewById(R.id.textView);
textView.setText(R.string.activityname);
private void setup() {
mAppComponent = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.authModule(new AuthModule(this)) //добавить
.build();
}
Intent intent = getIntent();
String message = intent.getStringExtra("text");
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent =new Intent(MainActivity.this, PreferenceScreen.class);
startActivity(intent);
}
});
}
}
Observable.create(
new Observable.OnSubscribe<T>() {
@Override
public void call(Subscriber<? super T> sub) {
sub.onNext(okhttp запрос);
sub.onCompleted();
}
})
.map(здесь обрабатывем ответ)
.timeout(5, TimeUnit.SECONDS) //таймаут
.retry(3) // попытки
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(результат -> выводим, сохраняем);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(MainActivity.this, about.class);
switch (position) {
case 0:
intent.putExtra("key", getResource().getString(R.string.tekst1));
break;
case 1:
intent.putExtra("key", getResource().getString(R.string.tekst2));
break ;
case 2:
intent.putExtra("key", getResource ().getString(R.string.tekst3));
break ;
}
startActivity (intent) ;
}
});
Intent intent = getIntent();
Bundle extras = intent.getExtras();
TextView.setText(extras.getString("key"))
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
public class NoSwipeViewPager extends ViewPager{
private boolean swipeable;
public NoSwipeViewPager(Context context) {
super(context);
}
public NoSwipeViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
this.swipeable = true;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (this.swipeable) {
return super.onTouchEvent(event);
}
return false;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (this.swipeable) {
return super.onInterceptTouchEvent(event);
}
return false;
}
public void setSwipeable(boolean swipeable) {
this.swipeable = swipeable;
}
}
<com.example......NoSwipeViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
private NoSwipeViewPager mViewPager;
..............
mViewPager = (NoSwipeViewPager) findViewById(R.id.container);
mViewPager.setSwipeable(false);