小编Mar*_*tin的帖子

Android:如何填写SwipeyTabs?

SwipeyTabs在我的应用程序中使用.我不确定如何填写标签内容.它甚至没有任何自己的xml.

我正在使用这样的标签:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_swipey_tabs);
    initViewPager(4, 0xFFFFFFFF, 0xFF000000);
    mSwipeyTabs = (SwipeyTabsView) findViewById(R.id.swipey_tabs);
    mSwipeyTabsAdapter = new SwipeyTabsAdapter(this);
    mSwipeyTabs.setAdapter(mSwipeyTabsAdapter);
    mSwipeyTabs.setViewPager(mPager);
}

private void initViewPager(int pageCount, int backgroundColor, int textColor) {
    mPager = (ViewPager) findViewById(R.id.pager);
    mPagerAdapter = new ExamplePagerAdapter(this, pageCount, backgroundColor, textColor);
    mPager.setAdapter(mPagerAdapter);
    mPager.setCurrentItem(1);
    mPager.setPageMargin(1);
}
Run Code Online (Sandbox Code Playgroud)

这是activity_swipey_tabs.xml布局:

<android.ex.com.viewpager.extension.SwipeyTabsView
    android:id="@+id/swipey_tabs"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#3B3B3B" />

<View
    android:id="@+id/colorline"
    android:layout_width="fill_parent"
    android:layout_height="2dip"
    android:layout_below="@+id/swipey_tabs"
    android:background="#FF91A438" />

<View
    android:id="@+id/blackline"
    android:layout_width="fill_parent"
    android:layout_height="1dip"
    android:layout_below="@+id/colorline"
    android:background="#FF000000" />

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/blackline" />
Run Code Online (Sandbox Code Playgroud)

有没有例子或教程? …

android

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

Android:LinkedIn OAuth回拨无效

OAuth在我的Android应用程序中使用LinkedIn .我已经有一个LinkedIn应用程序,消费者密钥和秘密,因此我可以成功请求.

一切都很好,直到回调.该网页不回电话,我的意思是onNewIntentonResume方法不调用.网页仅显示带参数的回调网址.我的意思是它看起来像:

callback_url://?oauth_token=324sdf&oath_verifier=as21dsf
Run Code Online (Sandbox Code Playgroud)

这是我的所有代码:

try {
    consumer = new CommonsHttpOAuthConsumer("ConsumerKey", "ConsumerSecret");
provider = new CommonsHttpOAuthProvider("https://api.linkedin.com/uas/oauth/requestToken", "https://api.linkedin.com/uas/oauth/accessToken", "https://api.linkedin.com/uas/oauth/authorize");
    final String url = provider.retrieveRequestToken(consumer, Constants.OAUTH_CALLBACK_URL);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_FROM_BACKGROUND);
    startActivity(intent);                          
} catch (Exception e) {
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

活性已经被定义为singleInstanceManifest.

有什么不对或缺失?

android oauth

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

Android:手势不好

我想Gesture在我的应用程序中使用.所以我已经查看了这个文档并创建了一个手势.然后将该手势复制到我所在的raw文件夹中res/.

从这里一切都没问题,然后我OnGesturePerformedListener就是如下所示:

if(!mLibrary.load()) {
    Log.d("Tag", "Couldn't load");
} else {
    Log.d("Tag", "Loaded");
    GestureOverlayView gesture = (GestureOverlayView) findViewById(R.id.gestures);
    gesture.addOnGesturePerformedListener(this);
}
Run Code Online (Sandbox Code Playgroud)

最后这是我的倾听者:

public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
    ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
    Log.d("Tag", "Performed");
    // We want at least one prediction
    if (predictions.size() > 0) {
        Prediction prediction = predictions.get(0);
        // We want at least some confidence in the result
        if (prediction.score > 1.0) {
            // Show the spell
            Toast.makeText(this, prediction.name, …
Run Code Online (Sandbox Code Playgroud)

android

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

Android:如何在使用SingleTask时清除意图堆栈

oAuth在应用程序中使用Twitter 库。用户使用Twitter帐户登录。

在活动A中,可以使用Twitter登录。用户登录后,我想启动没有历史记录的活动B。这是我所有的东西:

首先,,Manifest.xml因此我设置launchMode=singleTask为Twitter api请求:

<activity
    android:name=".A_Activity"
    android:label="@string/app_name"
    android:launchMode="singleTask"
    android:theme="@android:style/Theme.Black.NoTitleBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="my_twitter_scheme" />
    </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

这是我开始活动B的方式:

Intent i = new Intent(A.this, B.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Run Code Online (Sandbox Code Playgroud)

注意:我正在通过BroadcastReceiver实例调用活动B。

当我登录时,我的接收器正确地开始了活动B,但是不幸的是,当我按下“后退”按钮时,应用程序又回到了活动A。

我想这差不多了launchMode,正如我所说,Twitter需要这种选择。我究竟做错了什么?任何帮助或建议(也许关于Twitter)都将是很棒的。

android

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

Android:如何专门处理Back Press?

让我解释一下细节.

首先; 我知道如果用户按下并返回上一个活动,则前一个活动会onResume正确触发方法.这没关系.

我的应用程序中有一个根活动,它通过按钮指导4个不同的活动.我想学习,用户按哪个活动按下按钮?是否可以使用类似Handler或类似的东西?

实际上,我已经找到了一个解决方案.我有4个不同的静态布尔变量,每个变量代表一个Activity.让我在代码中显示:

public class MainActivity extends Activity { // This is root

    static Boolean activityA;
    static Boolean activityB;
    static Boolean activityC;
    static Boolean activityD;

    public void onClick(View v) {
        if(v == ActivitvyA) //of course psuedo 
             activityA = true
        //...there are similar controls
    }

    protected void onResume() {
        if(activitiyA) // If true, this means the user pressed back on ActivityA
    }

}
Run Code Online (Sandbox Code Playgroud)

你怎么看?有什么不同和有效的方式吗?

任何帮助都会很棒.

android

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

标签 统计

android ×5

oauth ×1